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

C Program to search an element in an array using Pointers

A separate function( search_function()) will be created where the array pointer will be declared and the searched element along with the size of an array …

C Program to find the sum of the digits of a number using recursion function

This C program calculates the sum of digits of a given number using recursion. Here’s a concise explanation: Function Definition: sumDigits(int n) This function calculates …

C program to find factorial of a number using Ternary operator with Recursion

Recursion refers to the function calling itself directly or in a cycle. Before we begin, you should have the knowledge of following in C Programming: …

C Program to Add Two Numbers Using Call by Reference

The program takes the two numbers from the user and passes the reference to the function where the sum is calculated. You may go through …

Find the output ab, cd, ef, g for the input a,b,c,d,e,f,g in Javascript and Python

In this tutorial, we will write a program to find a pairs of elements from an array such that for the input [a,b,c,d,e,f,g] we will …

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 …