Advertisement
Guest User

Untitled

a guest
May 25th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.50 KB | None | 0 0
  1. import java.util.Random;
  2.  
  3. public class DiceRoll {
  4.   public static void main(String[] args) {
  5.     int[] results = new int[11];
  6.     for (int i = 0; i < 36000; i++) {
  7.       results[Roll()] += 1;
  8.     }
  9.     for (int i = 0; i < 11; i++) {
  10.       System.out.print(i+2 + " : ");
  11.       System.out.println(results[i]);
  12.     }
  13.   }
  14.  
  15.   public static int Roll() {
  16.     int[] dice = new int[2];
  17.     dice[0] = new Random().nextInt(6);
  18.     dice[1] = new Random().nextInt(6);
  19.     return dice[0] + dice[1];
  20.   }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement