Java Programming | Grade System for marks


This is tutorial for grade system of marks in java. The program takes the marks from the user and calculates the percentage and prints it along with grade. The program is extendable. Go enjoy the program. Lets begin……….

Program for grade system for marks.

//import Scanner as we require it.
import java.util.Scanner;

// the name of our class its public
public class GradeSystem {
	//void main
		public static void main (String[] args)
			//declare int and float
			int a,b,c,tot;
			float per;

			//Declare input as scanner
			Scanner input = new Scanner(;

			//Take inputs
			 System.out.println("Enter marks of physics:");
			 a = input.nextInt();
			 System.out.println("Enter marks of chemistry:");
			 b = input.nextInt();
			 System.out.println("Enter marks of maths:");
		     c = input.nextInt();

		     tot = a + b + c;
		     per = tot/3;
			//print the Percentage and grade
			System.out.println("Percentage = "+per);

			System.out.println("Grade : A");
					System.out.println("Grade : B");
						System.out.println("Grade : C");
						System.out.println("Grade : D");


Enter marks of physics:
Enter marks of chemistry:
Enter marks of maths:
Percentage = 88.0
Grade : B

How it works

  1. The program prints the message to enter marks.
  2. The user enters marks.
  3. The percentage is calculated.
  4. If-else statement decides the grade and prints it.

Extending it

The program can be extended by using more marks and more grades. Go extend it.


  1. Import the Scanner.
  2. Declare the class as public
  3. Add the void main function
  4. Add system.out.println() function with the message to enter marks.
  5. Declare input as Scanner.
  6. Take the inputs and save it in variables.
  7. Calculate percentage and save it in variable.
  8. Add a if-else statement to find the grade according to percentage.
  9. Add system.out.println() function to print the grade and percentage.

At the end.

You learnt creating the Java program for Grade System for marks. So now enjoy the program.

Please comment on the post and share it.
And like it if you liked.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s