-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudentResult.java
More file actions
40 lines (30 loc) · 1.11 KB
/
StudentResult.java
File metadata and controls
40 lines (30 loc) · 1.11 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
import java.util.Scanner;
public class StudentResult {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter Student Name:");
String name = sc.nextLine();
System.out.println("Enter marks of 5 subjects:");
int m1 = sc.nextInt();
int m2 = sc.nextInt();
int m3 = sc.nextInt();
int m4 = sc.nextInt();
int m5 = sc.nextInt();
int total = m1 + m2 + m3 + m4 + m5;
double percentage = total / 5.0;
System.out.println("Total Marks = " + total);
System.out.println("Percentage = " + percentage);
if (percentage >= 90) {
System.out.println(name + " got Grade A+");
} else if (percentage >= 75) {
System.out.println(name + " got Grade A");
} else if (percentage >= 60) {
System.out.println(name + " got Grade B");
} else if (percentage >= 40) {
System.out.println(name + " got Grade C");
} else {
System.out.println(name + " is Fail");
sc.close();
}
}
}