-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudent_Grade_Cal.java
More file actions
67 lines (57 loc) · 2.68 KB
/
Student_Grade_Cal.java
File metadata and controls
67 lines (57 loc) · 2.68 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
63
64
65
66
67
import java.util.*;
public class Student_Grade_Cal {
static int summofarr;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter Total Subject No:--");
int n = sc.nextInt();
int[] marks = inputMarks_sum(sc, n);
float avg = (float) summofarr / n; // Correctly calculate average
// Display results based on average
if (avg >= 90) {
System.out.println("Your total score: " + summofarr);
System.out.println("Average percentage: " + avg+" %");
System.out.println("Your grade is: O");
} else if (avg >= 80 && avg < 90) {
System.out.println("Your total score: " + summofarr);
System.out.println("Average percentage: " + avg+" %");
System.out.println("Your grade is: E");
} else if (avg >= 70 && avg < 80) {
System.out.println("Your total score: " + summofarr);
System.out.println("Average percentage: " + avg+" %");
System.out.println("Your grade is: A+");
} else if (avg >= 60 && avg < 70) {
System.out.println("Your total score: " + summofarr);
System.out.println("Average percentage: " + avg+" %");
System.out.println("Your grade is: A");
} else if (avg >= 50 && avg < 60) {
System.out.println("Your total score: " + summofarr);
System.out.println("Average percentage: " + avg+" %");
System.out.println("Your grade is: B");
} else if (avg >= 40 && avg < 50) {
System.out.println("Your total score: " + summofarr);
System.out.println("Average percentage: " + avg+" %");
System.out.println("Your grade is: C");
} else {
System.out.println("Your total score: " + summofarr);
System.out.println("Average percentage: " + avg+" %");
System.out.println("You failed in Exam....!!!");
}
System.out.println("'O' for Outstanding Result\n'E' for Excellent Result\n'A+' for Very Good Result\n'A' for Good Result\n'B' for Satisfactory Result\n'C' for Bad Result");
sc.close();
}
// Method to input the marks and sum of them
public static int[] inputMarks_sum (Scanner sc, int n) {
int[] arr = new int[n];
for (int i = 0; i < n; i++) {
System.out.println("Enter your " + (i + 1) + " subject marks out of 100:");
arr[i] = sc.nextInt();
}
int sum = 0;
for (int i=0;i<n;i++) {
sum=sum+arr[i];
}
summofarr=sum;
return arr;
}
}