0

Hi I wrote code for Java program to simulate the rolling of 2 dice. The application should roll the dice 36,000 times. In a tabular format it should show the frequency of rolling 2,3,4,5,6,7,8,9,10,11,12 and also the percentage. It compiles alright but I am not getting the output. Can someone help me find out why I am not getting the output. Thank you for your help. Here is the code:

```
// Program simulates rolling two six-sided dice 36,000 times.
import java.util.Random;
public class Roll36
{
// simulate rolling of dice 36000 times
public void rollDice()
{
Random randomNumbers = new Random();
int face1; // number on first die
int face2; // number on second die
int totals[] = new int[ 13 ]; // frequencies of the sums
// initialize totals to zero
for ( int index = 0; index < totals.length; index++ )
totals[ index ] = 0;
// roll the dice
for ( int roll = 1; roll <= 36000; roll++ ) {
face1 = 1 + randomNumbers.nextInt( 6 );
face2 = 1 + randomNumbers.nextInt( 6 );
totals[ face1 + face2 ]++;
} // end for
// print the table
System.out.printf( "%3s%12s%12s\n",
"Sum", "Frequency", "Percentage" );
// ignore subscripts 0 and 1
for ( int k = 2; k < totals.length; k++ )
{
double percent = ( double )totals[ k ] / 36000 * 100;
System.out.printf( "%3d%12d%12.2f\n", k, totals[ k ], percent );
} // end for
} // end method rollDice
} // end class Roll36
```