-
Notifications
You must be signed in to change notification settings - Fork 0
/
Task_2_Student_Grade_Calculator.java
43 lines (37 loc) · 1.17 KB
/
Task_2_Student_Grade_Calculator.java
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
36
37
38
39
40
41
42
43
// TASK_02_STUDENT GRADE CALCULATOR //
import java.util.Scanner;
public class Task_2_Student_Grade_Calculator {
public static void main(String[] args) {
int count, i;
float totalMarks = 0, percentage, average;
Scanner scanner;
scanner = new Scanner(System.in);
System.out.println("Enter Number of Subject");
count = scanner.nextInt();
System.out.println("Enter Marks of " + count + " Subject");
for (i = 0; i < count; i++) {
totalMarks += scanner.nextInt();
}
System.out.println("Total MArks : " + totalMarks);
// Each subject is of 100 Marks
percentage = (totalMarks / (count * 100)) * 100;
switch ((int) percentage / 10) {
case 9:
System.out.println("Grade : A+");
break;
case 8:
case 7:
System.out.println("Grade : A");
break;
case 6:
System.out.println("Grade : B");
break;
case 5:
System.out.println("Grade : C");
break;
default:
System.out.println("Grade : D");
break;
}
}
}