Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.Random;
- class Main {
- public static void main(String[] args) {
- Scanner scanInput = new Scanner(System.in);
- Random rng = new Random();
- System.out.println("Hoevaak moet er gerold worden?");
- int numberOfDice = scanInput.nextInt();
- int[] dices = {0,0,0,0,0,0};
- int total = 0;
- for (int i=0; i<numberOfDice;i++) {
- int roll = rng.nextInt(6) + 1;
- total += roll;
- dices[roll - 1]++;
- }
- System.out.println("Een: " + dices[0]);
- System.out.println("Twee: " + dices[1]);
- System.out.println("Drie: " + dices[2]);
- System.out.println("Vier: " + dices[3]);
- System.out.println("Vijf: " + dices[4]);
- System.out.println("Zes: " + dices[5]);
- float average = (float)total / (float)numberOfDice;
- System.out.println("Gemiddelde: " + average);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement