Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pl.lba.flights;
- import java.util.Random;
- public class Main {
- public static final int ARRAY_SIZE = 20;
- public static void main(String[] args) {
- final Random random = new Random();
- int[] grades = new int[ARRAY_SIZE];
- for (int i = 0; i < ARRAY_SIZE; i++) {
- grades[i] = random.nextInt(6) + 1;
- }
- double sum = 0;
- for (int grade : grades) {
- System.out.println("Uczeń otrzymał " + grade + ".");
- sum = sum + grade;
- }
- final double average = sum / ARRAY_SIZE;
- System.out.println("Średnia ocen uczniów w klasie wyniosła " + average + ".");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement