Advertisement
Guest User

AvarageNumber

a guest
Jan 4th, 2021
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.49 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner sc = new Scanner(System.in);
  7.         int n = sc.nextInt();
  8.         double sum = 0;
  9.         for (double i = 0; i < n; i++) {
  10.  
  11.             Scanner scanner = new Scanner(System.in);
  12.                 double num = scanner.nextDouble();
  13.                 sum=sum+num;
  14.                
  15.         }
  16.         double result = sum/n;
  17.  
  18.         System.out.printf("%.2f", result);
  19.     }
  20. }
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement