-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGradeSystemForExam.java
More file actions
39 lines (27 loc) · 1.09 KB
/
Copy pathGradeSystemForExam.java
File metadata and controls
39 lines (27 loc) · 1.09 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
import java.util.Scanner;
public class GradeSystemForExam {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
for (int student = 1 ; student <= 3 ; student = student + 1){
System.out.println("Student " + student + ":");
int[] marks = new int[4];
int total = 0;
for (int i = 0; i < 4; i = i + 1) {
System.out.print("Enter marks for subject " + (i + 1) + ": ");
marks[i] = input.nextInt();
total = total + marks[i];
}
double average = total / 4.0;
String grade;
if (average >= 75 && average <= 100) {
grade = "Distinction";
} else if (average >= 50 && average <= 74) {
grade = "Credit";
} else {
grade = "Fail";
}
System.out.println("Average marks: " + average);
System.out.println("Grade: " + grade);
}
}
}