-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMethodChallenge.java
More file actions
33 lines (23 loc) · 1.36 KB
/
MethodChallenge.java
File metadata and controls
33 lines (23 loc) · 1.36 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
public class MethodChallenge {
public static void main(String[] args) {
displayHighScorePosition("DJ", calculateHighsScorePosition(1500));
displayHighScorePosition("AJ", calculateHighsScorePosition(1000));
displayHighScorePosition("BJ", calculateHighsScorePosition(500));
displayHighScorePosition("CJ", calculateHighsScorePosition(100));
displayHighScorePosition("EJ", calculateHighsScorePosition(25));
}
public static void displayHighScorePosition(String playerName, int playerPosition) {
System.out.println(playerName + " managed to get into position " + playerPosition + " on the high score list");
}
public static int calculateHighsScorePosition(int playerScore) {
int position = 4;
if (playerScore >= 1000) {
position = 1; // return 1;
} else if (500 <= playerScore) { //playerScore < 1000
position = 2; //return 2;
} else if (100 <= playerScore) { //playerScore<500
position = 3; //return 3;
} //else {}
return position;
}
}