Java Program to Read a Grade and Display the Equivalent Description

This is a Java Program to Read a Grade & Display the Equivalent Description.

Enter the grade of student as input. After that we match the character grade of student against the given cases using equal to operator (==) and hence generate the desired output.

Here is the source code of the Java Program to Read a Grade & Display the Equivalent Description. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.

  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4. public class Grade_Description 
  5. {
  6.     public static void main(String[] args) throws IOException 
  7.     {
  8.         char a;
  9.         BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
  10.         System.out.print("Enter grade of the student:");
  11.         a = (char) bf.read();
  12.         if(a == 'A' || a == 'a')
  13.         {
  14.             System.out.println("Student has got marks between above 80 out of 100.");
  15.         }
  16.         else if(a == 'B' || a == 'b')
  17.         {
  18.             System.out.println("Student has got marks above 60 but less than equal to 80 out of 100.");
  19.         }
  20.         else if(a == 'C' || a == 'c')
  21.         {
  22.             System.out.println("Student has got marks above 40 but less than equal to 60 out of 100.");
  23.         }
  24.         else
  25.         {
  26.             System.out.println("Student has failed");
  27.         }
  28.     }
  29. }

Output:

$ javac Grade_Description.java
$ java Grade_Description
 
Enter grade of the student:B
Student has got marks above 60 but less than equal to 80 out of 100.

Sanfoundry Global Education & Learning Series – 1000 Java Programs.

advertisement
advertisement

Here’s the list of Best Books in Java Programming, Data Structures and Algorithms.

If you find any mistake above, kindly email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.