hi everyone,
i am very new in java. can anyone help me to solve the following problem:

A school conducts a 100 mark exam for its student and grades them as follows:
Grade:
Grade A: Marks>75
Grade B: 75>Marks>60
Grade C: 60>Marks>50
Grade D: 50>Marks>40

Write ajava program to calculate the grades for a student, using if..else statement. use some given value to test the code.

thank you,
regards,
shantuli

macatangay.mharygrace commented: (Y) +0

Recommended Answers

All 39 Replies

I'm in a very giving mood today ;) Usually I don't just give the answer to homework problems outright like I am now. I'd rather see some effort put in on your end. So consider yourself very lucky. The following is the pseudocode for the program. Think about what each line means, and then translate it into Java syntax line by line.

input student's grade
if grade < 100 AND grade > 75 { student got an A }
else if grade < 75 AND grade > 60 { student got a B }
else if grade < 60 AND grade > 50 { student got a C }
else if grade < 50 AND grade > 40 { student got a D }
else { student got an F } // didn't fit into any of the above scenerios, so must be an F
print to screen what the student got

Hi shantuli,why not try this code as well.Have a lovely day.
Bobinson.

class Testy
{
   byte score;


Testy()
{
score=78;
}


public static void main(String arg[])

{
  Testy tst=new Testy();
   tst.processGrades();
}

public void processGrades()
{


if
(score >=75)
{
System.out.println("Your grade is A");
}
else
if
((score >= 60)&&( score <75 )) 
{
System.out.println("Your grade is B");
}
if
((score >=50 )&&(score<60))
{
System.out.println("Your grade is C");
}
else
if
((score >=40 )&&(score  <50))
{
System.out.println(" Your grade is D");
}
else
if
(score <40 )
{
System.out.println(" Sorry you have no part here,FAILED");
}

}
}

Dude, 2 things.
1. Put your code into the code tags
2. Don't just give him the answer to his homework, what good will that do him. You can help him and give him clues, but don't just do it for him. Also, your code seems overly complicated and there is no room for adjustment (i.e. the grade is always 78)

import java.util.Scanner;

public class CaseGrade {

	public static void main(String[] args) {
		Scanner input =  new Scanner (System.in);
		String name ;
		int grade;
		String exellent = "Exellent :";
		String veryGgood ="Very Good :";
		String good="Good :";
		String pass ="Pass :";
		String fail = "Fail :";
	
		int max = 0;
		int min = 100;
		int sum = 0;
		int avg ;
		int counter =0;
		
		boolean repeat ;
		while (repeat =true)
		{
			System.out.println("Enter Name : ");
			name =  input.next();
			System.out.println("Enter Grade : ");
			grade = input.nextInt();
			
			if (grade == -1 )
			{
				avg = sum / counter;
				System.out.println(" result = :");
				System.out.println(exellent +"\n"+ veryGgood +"\n"+ good +"\n"+ pass +"\n"+fail);
				System.out.println("maximum = "+ max +"\t");
				System.out.println("minimum = "+ min +"\t");
				System.out.println("\tAverage = " +avg);
				System.exit(0);
			}
			
			
			
			switch (grade/10)
			{
			case 100:
			case 9 :
				exellent += "\n"+ name + "\t" +grade+"\n";
			
				break;
			case 8 :
				veryGgood += "\n" + name + "\t" +grade +"\n";
			
				break ;
			
			case 7 :
				good += "\n" + name + "\t" +grade +"\n";
				
				break;
			case 6:
			case 5:
				pass += "\n" + name + "\t" +grade +"\n";
				break;

				default:
				fail +="\n" + name + "\t" +grade +"\n";
				break;

			}
			
			sum = sum + grade;
			counter = counter + 1;
		
			if (grade > max) 
			{
				max = grade;
			}
			if (grade < min)
			{
				min = grade;
			}
	
		}
	}

}

saadismail85 please use code tags and/or start a new thread.
For code tags click the button: (code) when you write your post

saadismail85 please use code tags and/or start a new thread.
For code tags click the button: (code) when you write your post

mmmmm tell me how cuz am new user here :-)

Here:

For code tags click the button: (code) when you write your post

mmmmm tell me how cuz am new user here :-)

[code=java]your code here [/code]

while (repeat =true)

Do you really want an infinite loop ? if yes you can use while(true) , not a good coding practice I would say.

while (repeat =true)

Do you really want an infinite loop ? if yes you can use while(true) , not a good coding practice I would say.

I believe it would be better to let him start a new thread, before responding to any questions.

Thanks

hi if i need help can someone help me here?i am a student of computer science but im not good in programming T_T

hi if i need help can someone help me here?i am a student of computer science but im not good in programming T_T

Start a new thread with your question

Java How to Program cover this. you should check the book out.

commented: You dug up this old thread to tell them to read about it in a book? -3

//There are ten students in class. Each student has taken five tests, and each test is worth 100 points. The grade is assigned as follows: if the average test score is greater than or equal to 90, the grade is A; if the average test score is greater than or equal to 80 and less than 90, the grade is B; if the average test score is greater than or equal to 70 and less than, the grade is C; if the average test score is greater than or equal to 60 and less than 70, the grade is D; otherwise, the grade is F. Note that the data consists of student's names and their test scores.Create a java program that will solve the problem.

package grade;

import javax.swing.*;
public class Grade
{
    private static String outputStr;
    public static void main(String[]args)
    {
        int test1,test2,test3,test4,test5,a,b,c,d,e,t,w,x,y,z;
        double average1,average2,average3;
        char A,B,C,D,F,Grade1,Grade2,Grade3;
        String student1Str,student2Str,student3Str,test1Str,test2Str,test3Str,test4Str,test5Str,aStr,bStr,cStr,dStr,eStr,tStr,wStr,xStr,yStr,zStr;

        {
        student1Str=JOptionPane.showInputDialog("Enter first student's name: ");
        student2Str=JOptionPane.showInputDialog("Enter second student's name: ");
        student3Str=JOptionPane.showInputDialog("Enter third student's name: ");
        test1Str=JOptionPane.showInputDialog("Enter the first score of the first student: ");
        test1=Integer.parseInt(test1Str);
        test2Str=JOptionPane.showInputDialog("Enter the second score of the first student: ");
        test2=Integer.parseInt(test2Str);
        test3Str=JOptionPane.showInputDialog("Enter the third score of the first student: ");
        test3=Integer.parseInt(test3Str);
        test4Str=JOptionPane.showInputDialog("Enter the fourth score of the first student: ");
        test4=Integer.parseInt(test4Str);
        test5Str=JOptionPane.showInputDialog("Enter the fifth score of the first student: ");
        test5=Integer.parseInt(test5Str);
        average1=(test1+test2+test3+test4+test5)/5;
        {
        if(average1>=90)
            Grade1='A';
        else if(average1>=80)
            Grade1='B';
        else if(average1>=70)
            Grade1='C';
        else if(average1>=60)
            Grade1='D';
        else
            Grade1='F';
        }


        }
        {
        aStr=JOptionPane.showInputDialog("Enter the first score of the second student: ");
        a=Integer.parseInt(aStr);
        bStr=JOptionPane.showInputDialog("Enter the second score of the second student: ");
        b=Integer.parseInt(bStr);
        cStr=JOptionPane.showInputDialog("Enter the third score of the second student: ");
        c=Integer.parseInt(cStr);
        dStr=JOptionPane.showInputDialog("Enter the fourth score of the second student: ");
        d=Integer.parseInt(dStr);
        eStr=JOptionPane.showInputDialog("Enter the fifth score of the second student: ");
        e=Integer.parseInt(eStr);
        average2=(a+b+c+d+e)/5;
        {
        if(average2>=90)
            Grade2='A';
        else if(average2>=80)
            Grade2='B';
        else if(average2>=70)
            Grade2='C';
        else if(average2>=60)
            Grade2='D';
        else
            Grade2='F';
        }
        }
        {
        tStr=JOptionPane.showInputDialog("Enter the first score of the second student: ");
        t=Integer.parseInt(tStr);
        wStr=JOptionPane.showInputDialog("Enter the second score of the second student: ");
        w=Integer.parseInt(wStr);
        xStr=JOptionPane.showInputDialog("Enter the third score of the second student: ");
        x=Integer.parseInt(xStr);
        yStr=JOptionPane.showInputDialog("Enter the fourth score of the second student: ");
        y=Integer.parseInt(yStr);
        zStr=JOptionPane.showInputDialog("Enter the fifth score of the second student: ");
        z=Integer.parseInt(zStr);
        average3=(t+w+x+y+z)/5;
        {
        if(average3>=90)
            Grade3='A';
        else if(average3>=80)
            Grade3='B';
        else if(average3>=70)
            Grade3='C';
        else if(average3>=60)
            Grade3='D';
        else
            Grade3='F';
        }
        }

        outputStr="Name: "+student1Str+"    "+"Average: "+average1+"    "+"Grade: "+Grade1+"\nName: "+student2Str+"   "+"Average: "+average2+"    "+"Grade: "+Grade2+"\nName: "+student3Str+"   "+"Average: "+average3+"    "+"Grade: "+Grade3;

        JOptionPane.showMessageDialog(null,outputStr,"Grade",JOptionPane.PLAIN_MESSAGE);


    }

}

Do you have a question? Or has your post any point other than reviving an old thread?

my instructor told us to create a flowchart that will accept prelim,midterm and final grade and will determine the average,identify if it's pass or failed . . . can someine help me with this. . . thanks in advance

commented: lazy homework kiddo... -3

Hi Rachelle, welcome to DaniWeb.
Please take a moment to familiarise yourself with the site rules
http://www.daniweb.com/community/rules
in particular, don't hijack old threads - start your own for a new question
and
you must show what you have done so far if you want help with homework.

JC

Construct the algorithm for a program that will prompt an instructor to enter the letter grade ('A', 'B', 'C', 'D', or 'F') earned by each of his students (we don’t know how many students are in the class). The program should output the number of students that passed and the number of students that failed.

commented: lazy homework kiddo... -3
commented: Read the previous post, then read the DaniWeb rules -3

we're not your homework service. Do your own assignments, if you get stuck on specific points, feel free to ask for help getting around those (though you might want to ask your teacher and class mates first, they're more in tune with the exact problems you're facing after all).

Thanks , it was useful for me

commented: No need to say thanks, this thread is 10 years old +0

I have completed by PSEUDOCODE assignment except I am having a hard time determining how I will account for an unknown amount of student grades entered and then divide that number by the total SUM of the Grades to get the GPA. I assume I will have a variable named Counter and that will be what holds the total number of Grades that are entered. I am currently using two nested while loops for student and grades.

thanks,
Aaron

Kit82polo : if you have a question, start a new thread. don't revive a thread which is not related to your question, and that has been dead for 10 years.

hello friends i don't understand java at all can anyone of you write a program for me

write a program to to calculate average marks of a class with 10 students and also display the number of students who scored above 85??

No.
People here will help you if you want to learn. Nobody will do it for you.
If you are willing to show effort start a new thread and show what you have done.

//StudentsGrade.java
//a program that generates grades for the marks
//capture marks for five subjects/course units
//calculate the GPA
//Display student details plus grades(letter, points), and GPA
please members help me here

Jeffrey, no.

if you had bothered to read the previous replies:

  1. this is NOT a "gimme codezzz" nor a "do my homework for me" service.
  2. the thread you are replying to is considered a 'Dead thread', it being 11 years old, answered, and all of that.
  3. if you want to ask a question: start your own thread.

When you start your own thread, keep this in mind:

posting only your assignment will not help you. It will make people think you're lazy and trying to cruise through school on their effort.
start with the coding yourself, post the code you thought would work, but doesn't work.

inform us of when it goes wrong: compile or run time. Tell us what error message you get, and what line of the code throws it.

Do remember, we are all volunteers willing to help you out improving your skills, not doing your work for you.

Good afternoon, An Assignment was given to me.
Question: Develop a scheduler, implement a cpu scheduler using at list 3 cpu scheduler, using any of the programming language of your choice. produce it output in a gang chart. Please I need answer to this question.

Unfortunately your need does not correspond to any impetus for us to do your homework for you. Try your best to code a solution then feel free to ask for help with the parts you are having trouble with.

A school conducts a 100 mark exam for its student and grades them as follows:
Grade:
Grade A: Marks>75
Grade B: 75>Marks>60
Grade C: 60>Marks>50
Grade D: 50>Marks>40

can u solve it in oracle plsql method

commented: read previous replies about creating your own threads and not reviving dead threads -3
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.