-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudentGradeCalculator.java
More file actions
67 lines (56 loc) · 1.85 KB
/
Copy pathStudentGradeCalculator.java
File metadata and controls
67 lines (56 loc) · 1.85 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 StudentGradeCalculator {
String name;
int maths;
int physics;
int chemistry;
int english;
int biology;
int total;
float avgPercent;
void input() {
Scanner sc = new Scanner(System.in);
System.out.println("Enter your name : ");
name = sc.nextLine();
System.out.println("Enter your marks in Mathematics : ");
maths = sc.nextInt();
System.out.println("Enter your marks in Physics : ");
physics = sc.nextInt();
System.out.println("Enter your marks in Chemistry : ");
chemistry = sc.nextInt();
System.out.println("Enter your marks in English : ");
english = sc.nextInt();
System.out.println("Enter your marks in Biology : ");
biology = sc.nextInt();
sc.close();
}
void calc() {
total = maths + physics + chemistry + english + biology;
avgPercent = total / 4;
}
void output() {
System.out.println("Hello " + name);
System.out.println("Your Total marks : " + total);
System.out.println("The average percent obtained is " + avgPercent);
if (avgPercent > 75) {
System.out.println("Grade : A");
}
else if ((avgPercent > 60) && (avgPercent < 75)) {
System.out.println("Grade : B");
}
else if ((avgPercent > 50) && (avgPercent < 60)) {
System.out.println("Grade : C");
}
else if ((avgPercent > 35) && (avgPercent < 50)) {
System.out.println("Grade : D");
}
else {
}
}
public static void main(String []args) {
StudentGradeCalculator sg = new StudentGradeCalculator();
sg.input();
sg.calc();
sg.output();
}
}