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 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,


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.

class Testy
   byte score;


public static void main(String arg[])

  Testy tst=new Testy();

public void processGrades()

(score >=75)
System.out.println("Your grade is A");
((score >= 60)&&( score <75 )) 
System.out.println("Your grade is B");
((score >=50 )&&(score<60))
System.out.println("Your grade is C");
((score >=40 )&&(score  <50))
System.out.println(" Your grade is D");
(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);
			switch (grade/10)
			case 100:
			case 9 :
				exellent += "\n"+ name + "\t" +grade+"\n";
			case 8 :
				veryGgood += "\n" + name + "\t" +grade +"\n";
				break ;
			case 7 :
				good += "\n" + name + "\t" +grade +"\n";
			case 6:
			case 5:
				pass += "\n" + name + "\t" +grade +"\n";

				fail +="\n" + name + "\t" +grade +"\n";

			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 :-)

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.


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.

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

//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: ");
        test2Str=JOptionPane.showInputDialog("Enter the second score of the first student: ");
        test3Str=JOptionPane.showInputDialog("Enter the third score of the first student: ");
        test4Str=JOptionPane.showInputDialog("Enter the fourth score of the first student: ");
        test5Str=JOptionPane.showInputDialog("Enter the fifth score of the first student: ");
        else if(average1>=80)
        else if(average1>=70)
        else if(average1>=60)

        aStr=JOptionPane.showInputDialog("Enter the first score of the second student: ");
        bStr=JOptionPane.showInputDialog("Enter the second score of the second student: ");
        cStr=JOptionPane.showInputDialog("Enter the third score of the second student: ");
        dStr=JOptionPane.showInputDialog("Enter the fourth score of the second student: ");
        eStr=JOptionPane.showInputDialog("Enter the fifth score of the second student: ");
        else if(average2>=80)
        else if(average2>=70)
        else if(average2>=60)
        tStr=JOptionPane.showInputDialog("Enter the first score of the second student: ");
        wStr=JOptionPane.showInputDialog("Enter the second score of the second student: ");
        xStr=JOptionPane.showInputDialog("Enter the third score of the second student: ");
        yStr=JOptionPane.showInputDialog("Enter the fourth score of the second student: ");
        zStr=JOptionPane.showInputDialog("Enter the fifth score of the second student: ");
        else if(average3>=80)
        else if(average3>=70)
        else if(average3>=60)

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




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

lazy homework kiddo...

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.

Read the previous post, then read the DaniWeb rules
lazy homework kiddo...

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).

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.


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??

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.

//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.

This article has been dead for over six months. Start a new discussion instead.