-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFloat_292.java
More file actions
24 lines (20 loc) · 809 Bytes
/
Float_292.java
File metadata and controls
24 lines (20 loc) · 809 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
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Float_292 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
long n = scanner.nextLong();
List<Float> numbers = new ArrayList<>();
for (int i = 0; i < n; i++) {
float newNum = scanner.nextFloat();
numbers.add(newNum);
}
System.out.println("Max: " + format(numbers.stream().max(Float::compare).get()));
System.out.println("Min: " + format(numbers.stream().min(Float::compare).get()));
System.out.println("Avg: " + format(numbers.stream().reduce(0.0f, Float::sum) / n));
}
private static String format(float f) {
return String.format(java.util.Locale.US, "%.3f", f);
}
}