daily pastebin goal
26%
SHARE
TWEET

Untitled

a guest Oct 12th, 2018 58 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top