forked from hmkcode/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGrade.java
More file actions
51 lines (48 loc) · 1.29 KB
/
Grade.java
File metadata and controls
51 lines (48 loc) · 1.29 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
public class Grade {
public String getLetterGrade(int score) {
if (score < 0 || score > 100) {
return "Invalid score";
} else if (score >= 80) {
return "A";
} else if (score >= 70) {
return "B";
} else if (score >= 50) {
return "C";
} else if (score >= 30) {
return "D";
} else {
return "F";
}
}
public double getGradePoint(int score) {
if (score < 0 || score > 100) {
return -1;
} else if (score >= 80) {
return 4.0;
} else if (score >= 70) {
return 3.0;
} else if (score >= 50) {
return 2.0;
} else if (score >= 30) {
return 1.0;
} else {
return 0.0;
}
}
public boolean isPassing(int score) { return score >= 30; }
public String getRemark(int score) {
if (score < 0 || score > 100) {
return "Invalid score";
} else if (score >= 80) {
return "Excellent";
} else if (score >= 70) {
return "Good";
} else if (score >= 50) {
return "Average";
} else if (score >= 30) {
return "Pass";
} else {
return "Fail";
}
}
}