Advertisement
Guest User

Untitled

a guest
Apr 11th, 2021
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int count = scanner.nextInt();
  7.  
  8.         float[] numbers = new float[count];
  9.  
  10.         float sum = 0;
  11.         int iterator = 0;
  12.  
  13.         if (count > 0) {
  14.             while (iterator < count) {
  15.                 numbers[iterator] = Float.parseFloat(scanner.next());
  16.                 sum += numbers[iterator];
  17.                 iterator++;
  18.             }
  19.             System.out.printf("%.2f", sum / count);
  20.         } else {
  21.             System.out.print("0.00");
  22.         }
  23.  
  24.     }
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement