public class Dice { public static void main (String[] argv) { // We will count the number of times our event of interest occurs. int count = 0; // Repeat experiment 100 times. for (int i=0; i<100; i++) { // Roll the dice. int m = (int) UniformRandom.uniform (1, 6); int n = (int) UniformRandom.uniform (1, 6); // See if the event of interest occurs. if (m+n == 7) count ++; } // Compute the fraction of time the event occurred. double avg = (double) count / 100; // Output. System.out.println ("Theoretical probability: " + (1.0/6.0)); System.out.println ("Estimated Probability: " + avg); } }