Advertisement
Guest User

Untitled

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