Skip to content

Commit 307d4af

Browse files
committed
Grade.java added in feature/grade branch
1 parent 9834913 commit 307d4af

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
public class Grade {
2+
public String getLetterGrade(int score) {
3+
if (score < 0 || score > 100) {
4+
return "Invalid score";
5+
} else if (score >= 80) {
6+
return "A";
7+
} else if (score >= 70) {
8+
return "B";
9+
} else if (score >= 50) {
10+
return "C";
11+
} else if (score >= 30) {
12+
return "D";
13+
} else {
14+
return "F";
15+
}
16+
}
17+
18+
public double getGradePoint(int score) {
19+
if (score < 0 || score > 100) {
20+
return -1;
21+
} else if (score >= 80) {
22+
return 4.0;
23+
} else if (score >= 70) {
24+
return 3.0;
25+
} else if (score >= 50) {
26+
return 2.0;
27+
} else if (score >= 30) {
28+
return 1.0;
29+
} else {
30+
return 0.0;
31+
}
32+
}
33+
34+
public boolean isPassing(int score) { return score >= 30; }
35+
36+
public String getRemark(int score) {
37+
if (score < 0 || score > 100) {
38+
return "Invalid score";
39+
} else if (score >= 80) {
40+
return "Excellent";
41+
} else if (score >= 70) {
42+
return "Good";
43+
} else if (score >= 50) {
44+
return "Average";
45+
} else if (score >= 30) {
46+
return "Pass";
47+
} else {
48+
return "Fail";
49+
}
50+
}
51+
}

0 commit comments

Comments
 (0)