This is very very strange, with this code and the jdk1.3
no matter how many times the dice rolls the 4th face
always is the highest number. I tried 10,000, 1 million,
1000 etc.... and the 4th face is always the highest number.
////////////////////////
import javax.swing.*;
public class Dice {
public static void main(
String args[])
{
int freq1 = 0, freq2 =0,
freq3 = 0, freq4 = 0,
freq5 = 0, freq6 =0, face;
for( int roll=1; roll <1000; roll++) {
face = 1+ ( int ) ( Math.random() * 6);
switch ( face) {
case 1:
++freq1;
break;
case 2:
++freq2;
break;
case 3:
++freq3;
case 4:
++freq4;
break;
case 5:
++freq5;
break;
case 6:
++freq6;
break;
}
}
JTextArea outputArea = new JTextArea( 16,22 );
outputArea.setText(
"Face\tFreq" +
"\n1\t" + freq1 +
"\n2\t" + freq2 +
"\n3\t" + freq3 +
"\n4\t" + freq4 +
"\n5\t" + freq5 +
"\n6\t" + freq6 );
JOptionPane.showMessageDialog( null, outputArea,
"Rolling Dice 1 thousand times",
JOptionPane.INFORMATION_MESSAGE );
System.exit ( 0 );
}
}