-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScoreLevelTest.java
More file actions
35 lines (27 loc) · 905 Bytes
/
ScoreLevelTest.java
File metadata and controls
35 lines (27 loc) · 905 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
package array;
import java.util.Scanner;
public class ScoreLevelTest {
public static void main(String[] args) {
System.out.println("insert numbers of students");
Scanner scanner = new Scanner(System.in);
int nums = scanner.nextInt();
System.out.println("insert score of each student");
// assign score into array and get the max one
int maxScore = 0;
int[] scores = new int[nums];
for (int i = 0; i < nums; i++) {
scores[i] = scanner.nextInt();
if(maxScore < scores[i]){
maxScore = scores[i];
}
}
// // get the maximum
// int maxScore = 0;
// for (int i = 0; i < nums; i++) {
// if(maxScore < scores[i]){
// maxScore = scores[i];
// }
// }
System.out.println("max score is " + maxScore);
}
}