-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaboveaverage.java
More file actions
28 lines (27 loc) · 954 Bytes
/
Copy pathaboveaverage.java
File metadata and controls
28 lines (27 loc) · 954 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
import java.util.ArrayList;
import java.util.Scanner;
public class aboveaverage {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int cases = scan.nextInt();
for (int i = 0; i<cases; i++) {
ArrayList<Integer> curStudents = new ArrayList<Integer>();
int students = scan.nextInt();
double average = 0.0;
double tally = 0.0;
for (int k = 0; k<students; k++) {
curStudents.add(scan.nextInt());
average = average + (double)curStudents.get(k);
}
average = average/students;
for (int j = 0; j<students; j++) {
if ((double)curStudents.get(j) > average) {
tally = tally+1;
}
}
tally = 100*(tally/students);
System.out.printf("%.3f%% %n", tally);
}
scan.close();
}
}