Simple Java Program 10: Grade Evaluation Using If-Else If-Else Statements

This time we will use If-Else If-Else because we are going to have multiple conditions.
In this program, the user will be asked to input his score and the program will display the remarks.
There will be different remarks displayed for each number bracket.
95-100 - excellent
90-94 - very good
85-89 - good
80-84- satisfactory
76-79 - study harder
75 - passed
74 below - failed

import java.util.Scanner;
public class Grades {

public static void main(String[] args) {
int grade;
System.out.println("Enter grade: ");
Scanner reader = new Scanner(System.in);
grade = reader.nextInt();

if (grade>=95)
{
System.out.println("Excellent!");
}
else if (grade>=90)
{
System.out.println("Very good!");
}
else if (grade>=85)
{
System.out.println("Good!");
}
else if (grade>=80)
{
System.out.println("Satisfactory");
}
else if (grade>=76)
{
System.out.println("Study harder");
}
else if (grade==75)
{
System.out.println("Passed");
}
else
{
System.out.println("Failed");

}

}

}

Here's the output:



Comments

  1. what if I wanna use joptionpane

    ReplyDelete
  2. All are saying the same thing repeatedly, but in your blog I had a chance to get some useful and unique information,
    I love your writing style very much, I would like to suggest your blog in my dude circle, so keep on updates.
    Java training in Btm layout
    Java training in Jaya nagar
    Java training in Electronic city
    Java training in Chennai
    Java training in USA

    ReplyDelete
  3. Good day!!! What if i wanna use switch case statement? What should i do?

    ReplyDelete

Post a Comment