-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGrading.java
More file actions
46 lines (43 loc) · 1.49 KB
/
Grading.java
File metadata and controls
46 lines (43 loc) · 1.49 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
import java.util.Scanner;
public class Grading {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Grading system of BIM students.");
System.out.println("Enter the number of the subjects : ");
int num = sc.nextInt();
System.out.println("Enter the maximum marks per subject : ");
double max = sc.nextDouble();
double maxmarks = max * num;
double totalmark = 0;
for (int i = 1; i <= num; i++) {
System.out.println("Enter the marks for subject " + i + " (out of 100)");
double marks = sc.nextDouble();
// ensure the valid marks
if (marks < 0 || marks > 100) {
System.out.println("Invalid marks entered. Please enter the marks between 0 to 100");
return;
}
totalmark = totalmark + marks;
}
double percentage = (totalmark / maxmarks) * 100;
double average = totalmark / num;
String grade;
if (average >= 90) {
grade = "Distinction";
} else if (average >= 80) {
grade = "Very Good";
} else if (average >= 70) {
grade = "First Division";
} else if (average >= 60) {
grade = "Second Division";
} else if (average >= 50) {
grade = "Pass in individual subject";
} else {
grade = "Fail";
}
System.out.println("Total marks : " + totalmark);
System.out.println("Average marks : " + average);
System.out.println("Percentage : " + percentage + "%");
System.out.println("Remarks/Division : " + grade);
}
}