Grade Points Program in java

In this post, we will learn Grade Points Program in java Programming language.

Question:

At Raffle’s Academy, students are given grade points to a maximum of 5 during their final exam. The grade points are mapped to Letter grades as follows.

Letter Grade             Grade points

O                                        5

A                                       >= 4.5 and <5.0

B                                        >= 4.0 and <4.5

C                                         >=3.0 and <4.0

D                                         >=2.0 and <3.0

E                                         >=1.0 and <2.0

F                                          >=0.0 and <1.0

Write a program to that get’s an input between 0 and 5 and outputs the grade of the student.

Sample input:

Enter the grade point: 4.5

Sample output:

Grade: A

Sample input:

Enter the grade point: 3.4

Sample output:

Grade: C

Sample input:

1.2

Sample output:

Grade: E

CODE:

import java.util.*;
public class Main
{
    public static void main (String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.print("Enter the grade point: ");
        double grd=sc.nextDouble();
        if(grd==5)
        {
            System.out.println("Grade: O");
        }
        else if(grd>=4.5)
        {
            System.out.println("Grade: A");
        }
        else if(grd>=4.0)
        {
            System.out.println("Grade: B");
        }
        else if(grd>=3.0)
        {
            System.out.println("Grade: C");
        }
        else if(grd>=2.0)
        {
            System.out.println("Grade: D");
        }
        else if(grd>=1.0)
        {
            System.out.println("Grade: E");
        }
        else
        {
            System.out.println("Grade: F");
        }
    }
}

Sharing Is Caring

Leave a Comment