// Application to show random number generator public class RollDice { public static void main (String[] args) { int face; int frequency[]; frequency = new int[6]; /* Use random to generate real random numbers between 0 and 1, and scale them to "faces" between 1 and 6 */ for(int roll=1; roll <= 6000; roll++) { face = 1 + (int) (Math.random() * 6); ++frequency [face-1]; } // print results System.out.println("\n" + "Face " + "Frequency"); for (face = 0; face < frequency.length; face++) System.out.println(String.valueOf(face+1) + " " + String.valueOf(frequency[face])); } }