forked from scottnakada/HackerRank-Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGrade.java
More file actions
32 lines (29 loc) · 893 Bytes
/
Grade.java
File metadata and controls
32 lines (29 loc) · 893 Bytes
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
public class Grade extends Student {
/* Local variables for the Grade class */
private int score;
/* Constructor for the Grade Class */
Grade (String firstNameIn, String lastNameIn, int phoneIn, int scoreIn) {
/* Create a Student object */
super(firstNameIn, lastNameIn, phoneIn);
/* Initialize the local variables for the Grade class */
score = scoreIn;
}
/* Calculate the grade, based upon the student's score */
public char calculate() {
/* 0-39 = 'D' */
if (score < 40) {
return 'D';
/* 40-59 = 'B' */
} else if (score < 60) {
return 'B';
/* 60-74 = 'A' */
} else if (score < 75) {
return 'A';
/* 75-89 = 'E' */
} else if (score < 90) {
return 'E';
}
/* Otherwise, grade is 'O' */
return 'O';
}
}