Advertisement
Guest User

Untitled

a guest
Oct 12th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. package pl.lba.flights;
  2.  
  3. import java.util.Random;
  4.  
  5. public class Main {
  6.  
  7. public static final int ARRAY_SIZE = 20;
  8.  
  9.  
  10. public static void main(String[] args) {
  11. final Random random = new Random();
  12.  
  13. int[] grades = new int[ARRAY_SIZE];
  14. for (int i = 0; i < ARRAY_SIZE; i++) {
  15. grades[i] = random.nextInt(6) + 1;
  16. }
  17.  
  18. double sum = 0;
  19.  
  20. for (int grade : grades) {
  21. System.out.println("Uczeń otrzymał " + grade + ".");
  22. sum = sum + grade;
  23. }
  24.  
  25.  
  26. final double average = sum / ARRAY_SIZE;
  27.  
  28. System.out.println("Średnia ocen uczniów w klasie wyniosła " + average + ".");
  29.  
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement