Advertisement
Guest User

Untitled

a guest
Apr 25th, 2020
654
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.86 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Practice {
  4.  
  5.     public static void main(String[] args) {
  6.  
  7.         Scanner scanner = new Scanner(System.in);
  8.         String x = scanner.nextLine();
  9.         int n1 = Integer.parseInt(x);
  10.         double average = 0;
  11.         double min = 1000000;
  12.         double max = -1000000;
  13.         double sum = 0;
  14.         double n2 = 0;
  15.  
  16.         for (int i = 0; i < n1; i++) {
  17.             n2 = Double.parseDouble(scanner.nextLine());
  18.             if (n2 < min) {
  19.               min = n2;
  20.             }
  21.             if (n2 > max) {
  22.                 max = n2;
  23.             }
  24.             sum += n2;
  25.         }
  26.         average = sum / n1;
  27.  
  28.         System.out.printf("min=%.2f%n", min);
  29.         System.out.printf("max=%.2f%n", max);
  30.         System.out.printf("sum=%.2f%n", sum);
  31.         System.out.printf("avg=%.2f", average);
  32.  
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement