
A Java program to simulate throwing a die (singular of dice) 6000 times and store the frequency with which each face of the die is uppermost after each throw in an array.
A couple of sample outputs follow: 1: 1020 2: 1015 3: 990 4: 1036 5: 941 6: 998
1: 984 2: 1016 3: 967 4: 1028 5: 985 6: 1020

mate, you cant cheat on your assignment1 FIT1002 by getting other people to code it for you. You should know this by now. If you have any problems you should go see your tutor. Lucky this doesnt get taken against you

import java.util.Random;
public class DiceRolling
{
public static void main( String[] args)
{
Random randomNumbers = new Random();
int[] array = new int[ 7 ];
int dice;
for ( int roll = 1; roll <=6000; roll++ )
{
dice = 1 + randomNumbers.nextInt ( 6 );
++array[dice];
}
System.out.println("Face Frequency");
for ( int face = 1; face < array.length; face++ )
System.out.println( face+"\t "+ array[ face ] );
}
}
The above code throw a dice 6000 times and and store the frequency with which each face of the die after each throw in an array.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.