Okay so I have to find the number of times 2 die land on 2-12 /and the percentage of getting a 1 a 2 and so on rolling it 10million times.

So far I have this:

Code :

import java.util.Random; public class MonteCarlo { /** * @param args */ public static void main(String[] args) { { Random randomNumbers = new Random(); // Generates random numbers int[] array = new int[ 13 ]; // Declares the array int dice1; int dice2; //Roll the die 36,000 times for ( int roll = 1; roll <=10000000; roll++ ) { int die1 = randomNumbers.nextInt ( 6 )+ 1; int die2 = randomNumbers.nextInt ( 6 )+ 1; int total = die1 + die2; ++array[total]; } // outputs array values int nRolls = 100, nDice = 6; // default values nRolls = 10000000; //10,000,000 rolls of the dice nDice = 6; // six sides of the dice int minSum = 2, maxSum = 2 * nDice; //lowest sum of dice is two. Max sum is 2 times the number of sides. minSum= 2, maxSum=12 int[] Prop = new int[maxSum - minSum + 1]; Random rand = new Random(); //random for (int iter = 1; iter <= nRolls; iter++) { int throw1 = 1 + rand.nextInt(nDice), throw2 = 1 + rand.nextInt(nDice); int sum = throw1 + throw2; Prop[sum - minSum]++; } System.out.println("Number of rolls: " + nRolls + " on a six sided dice"); // Using int nRolls System.out.println("Number of sides of the dice: " + nDice); //Usin int nDice System.out.println("Sum of Dice Percentage Number Of Times Rolled"); // created space so it creates space in the output for (int i = 0; i < Prop.length; i++) { System.out.println(String.format(" %2d %5.2f%%", i + minSum, Prop[i] * 100.0 / nRolls)); // System.out.println(" " + (i+minSum) + " " + (hist[i]*100.0/nRolls); }{ for ( int face = 2; face < array.length; face++ ) System.out.printf( "%4d%10d\n", face, array[ face ] ); } } // end main }} // end class DiceRollin

The output is:

Code :

Number of rolls: 10000000 on a six sided dice Number of sides of the dice: 6 Sum of Dice Percentage Number Of Times Rolled 2 2.78% 3 5.56% 4 8.32% 5 11.11% 6 13.90% 7 16.67% 8 13.88% 9 11.11% 10 8.33% 11 5.55% 12 2.78% 555185 832554 1111462 1389278 1667420 1389082 1111436 832328 554695 277347

As you can see i do not want the numbers 2-12 again. I need the out put to look like THIS:

Code :

Number of rolls: 10000000 on a six sided dice Number of sides of the dice: 6 Sum of Dice Percentage Number Of Times Rolled 2 2.78% 279213 3 5.56% 555185 4 8.32% 832554 5 11.11% 1111462 6 13.90% 1389278 7 16.67% 1667420 8 13.88% 1389082 9 11.11% 1111436 10 8.33% 832328 11 5.55% 554695 12 2.78% 277347

Please any advice would help.