/** * Performs repeated dice roll simulations and maintains stats. * @author Dave Reed * @version 8/25/08 */ public class DiceStats { public final static int DIE_SIDES = 6; public final static int NUM_ROLLS = 10000; public static void main(String[] args) { int[] counts = new int[2*DIE_SIDES+1]; Die die = new Die(DIE_SIDES); for (int i = 0; i < NUM_ROLLS; i++) { counts[die.roll() + die.roll()]++; } for (int i = 2; i < counts.length; i++) { System.out.println(i + ": " + counts[i] + " (" + (100.0*counts[i]/NUM_ROLLS) + "%)"); } } }