Advertisement
Guest User

Untitled

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