-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClassArray3.java
More file actions
46 lines (35 loc) · 1.09 KB
/
Copy pathClassArray3.java
File metadata and controls
46 lines (35 loc) · 1.09 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
import java.util.Scanner;
public class ClassArray3{
public static void main(String... args){
Scanner input = new Scanner(System.in);
int[] scores;
System.out.print("Enter the number of scores: ");
int scoreNum = input.nextInt();
scores = new int[scoreNum];
for(int count = 0; count< scoreNum; count++){
System.out.printf("Enter the scores %d: ", count);
int score = input.nextInt();
scores[count] = score;
}
double total = 0;
for(int count = 0; count< scores.length; count++){
System.out.printf("%d%s ", scores[count], ",");
total += scores[count];
}
int largest = scores[0];
for(int count = 0; count < scores.length; count++){
if (largest < scores[count]){
largest = scores[count];
}
}
System.out.printf("The largest number is: %d%n", largest);
int lowest = scores[0];
for(int count = 0; count < scores.length; count++){
if(scores[count] < lowest)
lowest = scores[count];
}
System.out.printf("The lowest number is: %d%n", lowest);
double average = total / scores.length;
System.out.print("The average number is: " + average);
}
}