-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudentGradeCalculator.java
More file actions
55 lines (41 loc) · 1.51 KB
/
StudentGradeCalculator.java
File metadata and controls
55 lines (41 loc) · 1.51 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
import java.util.Scanner;
public class StudentGradeCalculator {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double totalmarks = 0;
double averageMarks;
// Input number of subjects
System.out.print("Enter the number of subjects: ");
int numSubjects = scanner.nextInt();
System.out.print("Enter the english marks :");
int a = scanner.nextInt();
System.out.print("Enter the Hindi marks :");
int b = scanner.nextInt();
System.out.print("Enter the sst marks :");
int c = scanner.nextInt();
System.out.print("Enter the maths marks :");
int e = scanner.nextInt();
System.out.print("Enter the evs marks :");
int d = scanner.nextInt();
totalmarks = (a+b+c+d+e);
System.out.print("The total marks is :");
System.err.println(totalmarks);
averageMarks = totalmarks/numSubjects;
System.err.println("The average marks is: ");
System.out.println(averageMarks);
char grade;
if (averageMarks>=90){
grade = 'A';
}else if(averageMarks>=80){
grade = 'B';
}else if(averageMarks>=70){
grade = 'C';
}else if (averageMarks>=60){
grade = 'D';
}else{
grade = 'F';
}
System.out.println("Grade: " + grade);
scanner.close();
}
}