223k views
2 votes
Submit program Grades using Swicth - Case (Java)

Write a program to enter the grade of a student as integer from the key board such that the out put will indicate the letter grade if it is an A,B,C,D. or F using Switch - Case.

90 and up is A

80 and up is b

70 and up is C

60 and up is D

all under 60 is F

1 Answer

3 votes

Answer:

import java.util.*;

import java.util.Scanner;

import java.io.*;

public class Main

{

public static void main(String[] args) {

System.out.println("Enter the percentage:");

Scanner sc1= new Scanner(System.in);

int percent=sc1.nextInt();

switch((int)percent/10)

{

case 10:

case 9:

System.out.println("Grade: A");

break;

case 8:

System.out.println("Grade: B");

break;

case 7:

System.out.println("Grade: C");

break;

case 6:

System.out.println("Grade: D");

break;

case 5:

case 4:

case 3:

case 2:

case 1:

System.out.println("Grade: F");

break;

}

}

}

Step-by-step explanation:

The program is as mentioned above. The grades are alloted as per the marks.

User Kendrick
by
5.4k points