-
Notifications
You must be signed in to change notification settings - Fork 702
Expand file tree
/
Copy pathGradingSystem.java
More file actions
55 lines (47 loc) · 1.47 KB
/
GradingSystem.java
File metadata and controls
55 lines (47 loc) · 1.47 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
package _03_03b;
public class GradingSystem {
public boolean isAPass(int percentage) {
// Return true if the percentage is higher than or equal to 60.
// Otherwise return false.
if (percentage >= 60) {
return true;
} else {
return false;
}
}
public char getGrade(int percentage) {
// If the percentage is 90 or above, return 'A'.
// If it's 80-89, return 'B'.
// If it's 70-79, return 'C'.
// If it's 60-69, return 'D'.
// If it's less than 60, return 'F'.
if (percentage >= 90) {
return 'A';
} else if(percentage >=80) {
return 'B';
} else if(percentage >=70){
return 'C';
} else if(percentage >=60) {
return 'D';
} else {
return 'F';
}
}
public String retakeMessage(int percentage, boolean allowedToRetake) {
// If percentage is less than 60 and allowedToRetake is true, return a String
// that says "The student has been entered for a retake."
// If percentage is less than 60 and allowedToRetake is false, return a String
// that says "The student is not allowed to retake this exam."
// If percentage is 60 or higher, return a String that says "A retake is not
// required."
if(percentage < 60 && allowedToRetake == true) {
return "The student has been entered for a retake.";
}
else if (percentage <60 && !allowedToRetake) {
return "Can not retake";
}
else {
return "A retake is not required";
}
}
}