-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudentGradeCalculator.java
More file actions
62 lines (45 loc) · 1.52 KB
/
Copy pathStudentGradeCalculator.java
File metadata and controls
62 lines (45 loc) · 1.52 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import java.util.Scanner;
public class StudentGradeCalculator{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String name;
int m1, m2, m3, m4, m5;
int total;
double percentage;
System.out.println("Enter Student Name:");
name = sc.nextLine();
System.out.println("Enter Marks of 5 Subjects:");
System.out.print("Subject 1: ");
m1 = sc.nextInt();
System.out.print("Subject 2: ");
m2 = sc.nextInt();
System.out.print("Subject 3: ");
m3 = sc.nextInt();
System.out.print("Subject 4: ");
m4 = sc.nextInt();
System.out.print("Subject 5: ");
m5 = sc.nextInt();
total = m1 + m2 + m3 + m4 + m5;
percentage = total / 5.0;
System.out.println("\n----- RESULT -----");
System.out.println("Student Name: " + name);
System.out.println("Total Marks: " + total);
System.out.println("Percentage: " + percentage);
if (percentage >= 90) {
System.out.println("Grade: A+");
}
else if (percentage >= 75) {
System.out.println("Grade: A");
}
else if (percentage >= 60) {
System.out.println("Grade: B");
}
else if (percentage >= 35) {
System.out.println("Grade: C");
}
else {
System.out.println("Grade: FAIL");
}
sc.close();
}
}