File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed
src/main/java/com/thealgorithms Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments