-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSwitchGradeExample.java
More file actions
35 lines (32 loc) · 931 Bytes
/
SwitchGradeExample.java
File metadata and controls
35 lines (32 loc) · 931 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import java.util.Scanner;
public class SwitchGradeExample{
public static void main(String[] args){
int count,i;
float totalmarks=0, percentage, average;
Scanner sc=new Scanner(System.in);
System.out.print("Enter Number of Subjects: ");
count =sc.nextInt();
System.out.print("Enter Marks of "+count+" Subject: ");
for(i=0;i<count;i++){
totalmarks +=sc.nextInt();
}
System.out.println("Total Marks: "+totalmarks);
percentage=(totalmarks/(count*100))*100;
switch((int)percentage/10){
case 9: System.out.println("Grade: A+");
break;
case 8: System.out.println("Grade: A");
break;
case 7: System.out.println("Grade: B");
break;
case 6: System.out.println("Grade: C");
break;
case 5: System.out.println("Grade: D");
break;
case 4: System.out.println("Grade: E");
break;
default: System.out.println("Grade: F");
break;
}
}
}