-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHighscore.java
More file actions
46 lines (26 loc) · 810 Bytes
/
Copy pathHighscore.java
File metadata and controls
46 lines (26 loc) · 810 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import java.util.Scanner;
public class Highscore{
public static void main (String[]args){
Scanner input = new Scanner(System.in);
String highestScore = "";
int largestScore = -234567890;
System.out.print ("enter number of students: ");
int number = input.nextInt();
int largestNumber = 0;
for(int counter =0; counter <= number; counter = counter + 1){
System.out.print ("enter more names: ");
String name = input.next();
System.out.print ("score");
int score= input.nextInt();
if (score > largestNumber){
largestNumber = score;
highestScore = name;
}
}
if (number == 0){
System.out.print("wrong number");
}
System.out.println ("The highestScore: " + largestNumber);
System.out.println ( "student with highestScore: "+ highestScore);
}
}