Advertisement
Guest User

Untitled

a guest
Jul 13th, 2019
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1.  
  2. import java.text.DecimalFormat;
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7. public static void main(String[] args) {
  8. DecimalFormat df2 = new DecimalFormat("0.00");
  9. Scanner entry1 = new Scanner(System.in);
  10. Scanner entry2 = new Scanner(System.in);
  11.  
  12.  
  13. double n = Double.parseDouble(entry1.nextLine());
  14. double numbers;
  15. double sum = 0;
  16. double result = 0;
  17.  
  18. for (int i = 1; i <= n; i++) {
  19. numbers = Double.parseDouble(entry2.nextLine());
  20. sum = sum + numbers;
  21. result = sum / n;
  22. }
  23.  
  24. System.out.print(df2.format(result));
  25.  
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement