Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Practice {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String x = scanner.nextLine();
- int n1 = Integer.parseInt(x);
- double average = 0;
- double min = 1000000;
- double max = -1000000;
- double sum = 0;
- double n2 = 0;
- for (int i = 0; i < n1; i++) {
- n2 = Double.parseDouble(scanner.nextLine());
- if (n2 < min) {
- min = n2;
- }
- if (n2 > max) {
- max = n2;
- }
- sum += n2;
- }
- average = sum / n1;
- System.out.printf("min=%.2f%n", min);
- System.out.printf("max=%.2f%n", max);
- System.out.printf("sum=%.2f%n", sum);
- System.out.printf("avg=%.2f", average);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement