-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay_11_challenge_methods.java
More file actions
51 lines (43 loc) · 1.96 KB
/
Copy pathDay_11_challenge_methods.java
File metadata and controls
51 lines (43 loc) · 1.96 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
package Programing.Section4;
// Create a method called displayHighScorePosition
// it should a players name as a parameter, and a 2nd parameter as a position in the high score table
// You should display the players name along with a message like " managed to get into position " and the
// position they got and a further message " on the high score table".
//
// Create a 2nd method called calculateHighScorePosition
// it should be sent one argument only, the player score
// it should return an in
// the return data should be
// 1 if the score is >=1000
// 2 if the score is >=500 and < 1000
// 3 if the score is >=100 and < 500
// 4 in all other cases
// call both methods and display the results of the following
// a score of 1500, 900, 400 and 50
public class Day_11_challenge_methods {
public static void main(String[] args) {
int checkinghighscoreposition = calculatehighscorepositions(1500);
displayhighscorepositions("Aarush",checkinghighscoreposition);
checkinghighscoreposition = calculatehighscorepositions(900);
displayhighscorepositions("Alpha",checkinghighscoreposition);
checkinghighscoreposition = calculatehighscorepositions(400);
displayhighscorepositions("Putin",checkinghighscoreposition);
checkinghighscoreposition = calculatehighscorepositions(50);
displayhighscorepositions("Death",checkinghighscoreposition);
}
public static void displayhighscorepositions (String name, int positions){
System.out.println(name+ " managed to get into position " +positions +" on the high score table.");
}
public static int calculatehighscorepositions (int score){
if (score >= 1000){
return 1;
}
else if (score >=500) { // in this (score>= 500 && score<1000)
return 2;
}
else if (score >= 100) {
return 3;
}
else return 4;
}
}