-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgradesTool.java
More file actions
35 lines (33 loc) · 1010 Bytes
/
Copy pathgradesTool.java
File metadata and controls
35 lines (33 loc) · 1010 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 JavaMethodsPractice;
public class gradesTool {
public static void main(String[] args) {
int[] testScores = {85, 92, 45, 60, 95, 30, 88, 72};
System.out.println(findHighest(testScores)+" was the highest score!");
printFailing(testScores);
}
static int findHighest(int[] scores) {
int max = scores[0];
for (int score: scores) {
if (score > max) {
max = score;
}
}
return max;
}
static void printFailing(int[] scores) {
int i = 0;
for (int score: scores) {
if (score < 65 && i == 0){
System.out.println("scores that failed - ");
System.out.println(score);
i++;
} else if (score < 65) {
System.out.println(score);
i++;
}
}
if (i==0) {
System.out.println("Everyone Passed!");
}
}
}