-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmarkscalculator.java
48 lines (40 loc) · 1.09 KB
/
markscalculator.java
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
import java.util.*;
public class markscalculator {
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
System.out.println("ENTER THE NUMBER OF SUBJECTS:");
int n= sc.nextInt();
int marks[]= new int[n];
for(int i=0 ; i<n ; i++){
System.out.println("ENTER THE MARKS FOR SUBJECT " +(i+1)+ ":" );
marks[i]= sc.nextInt();
}
int total=0;
for (int mark : marks) {
total += mark;
}
float avg= (float) total / n * 100;
String grade;
if (avg>=90){
grade= "A";
}
else if (avg>=80){
grade= "B";
}
else if (avg>=55){
grade= "C";
}
else if (avg>=40){
grade= "D";
}
else if (avg>=25){
grade= "E";
}
else{
grade= "F";
}
System.out.println("TOTAL MARKS OBTAINED:" +total);
System.out.println("AVERAGE MARKS OBTAINED:" +avg);
System.out.println("GRADE OBTAINED:" +grade);
}
}