Advertisement
HristoBaychev

Untitled

Sep 25th, 2021
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. package com.company;
  2. import java.util.Scanner;
  3. import java.util.Scanner;
  4.  
  5. public class minmaxav {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8. int n = Integer.parseInt(scanner.nextLine());
  9. int sum = 0;
  10. double avg = 0;
  11. int minValue = 0;
  12. int maxValue = 0;
  13. int[] inputs = new int[n];
  14. for (int i = 0; i < n; i++) {
  15. inputs[i] = Integer.parseInt(scanner.nextLine());
  16. }
  17. for (int i = 0; i < n; i++) {
  18. sum = sum + inputs[i];
  19. avg = sum / n;
  20.  
  21. }
  22.  
  23. System.out.printf("\nThe sum of all numbers is: %d", sum);
  24. System.out.printf("\nThe avg of all numbers is: %f", avg);
  25.  
  26.  
  27. }
  28.  
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement