Java Program to Calculate Grade of Students2 min read

In this tutorial, we will write a java program to calculate the grade of the student. Before that, you should have knowledge on the following topic in java:

Java Program to calculate and display Student Grades: The program simply takes a user input for the number of subjects and then for the marks obtained on each of those subjects.

Then the sum of the marks is calculated and then the average of that sum is calculated. The average is calculated by dividing the sum of the marks by the number of subjects. Lastly, using the if-else ladder the grade is displayed on the screen.

The grade is printed by following grade slab:

  • If marks > 80, Grade is A
  • If marks > 60 and <= 79, Grade is B
  • If marks > 40 and <= 59, Grade is C
  • Else Grade is D

You can change the grades according to your need and your question. We will perform two different programs:

  1. Using if else ladder
  2. Using Switch Case

Java program to find grade of a student using if else ladder

Output:

Enter the number of subjects: 5
Enter Marks for 5 Subjects:
55
84
72
67
90
Your Grade: B


Java Program to find grade of a student using switch case

Enter the Number of Subjects:
4
Enter Marks for 4 Subjects:
84
79
92
85
Percentage Obtained: 85.0
Your Grade: A


MORE

String Pattern Programs in C

In this tutorial, we will write various C pattern programs for String. Before that, you may go through the following topics in C. for loop …
Read More

Java Program to Find pair of Integers in Array whose sum is given Number

In this tutorial, we will write a program to find a pair of elements from an array whose sum equals a given number in java …
Read More

Program to Print Diamond Alphabet Patterns in C

In this tutorial, we will learn to write a C program to print Diamond patterns using alphabets/characters. However, in this tutorial, we will create a …
Read More

Half Diamond Pattern in C using Alphabets

In this tutorial, we will learn and code the half diamond alphabet patterns in C programming language. However, in this tutorial, we will create a …
Read More

Half Pyramid of Alphabets in C

In this tutorial, we will learn and code alphabet patterns in C programming language specifically the Half pyramid of alphabets in C programming. However, in …
Read More

Inverted Half Pyramid Pattern of Alphabets in C

In this tutorial, we will write a C program to print half Pyramid using alphabets/characters. Before that, you may go through the following topic in …
Read More