Coders Packet

Grade Calculator using Java

By Dendi Keerthi

This is a simple Grade Calculator using Java. With this, the average of the total marks obtained is calculated and the respective grade is displayed.

Implementation of Grade Calculator

In this simple Grade Calculator, the marks of the subjects are given as input. The Calculator calculates the average of the given marks obtained and displays the respective grade along with a message.

We use the Scanner class to get the input. This is available in java.util package.

We make use of the following in our program:

-> For loop

-> if-else-if statements

-> Arrays


The following code gives the complete idea of the Grade Calculator.

import java.util.Scanner;

public class GradeCalculator
public static void main(String args[])
System.out.println("Student Grade Calculator");

int marks[] = new int[6];
int i;
float total=0; avg;
Scanner scanner = new Scanner(;

for(i=0; i<6; i++) {
System.out.print("Enter Marks of Subject"+(i+1)+":");
marks[i] = scanner.nextInt();
total = total + marks[i];

avg = total/6;
System.out.print("The student Grade is: ");
System.out.println("Congratulations Maintain it.");
else if(avg>=60 && avg<80)
System.out.println("Can do better.");
else if(avg>=40 && avg<60)
System.out.println("Need to be improved.");
else if(avg>=26 && avg<40)
System.out.println("Need to be improved.");
System.out.println("Better Luck Next Time.");



We can also calculate the average and obtain a grade for any number of subjects by changing the value in the for loop and Array conditions and entering the required value and obtain the respective result.


Download project

Reviews Report

Submitted by Dendi Keerthi (dendikeerthi)

Download packets of source code on Coders Packet