I'm working on a program for class that uses the method Math.random( ) to generate random integers between 1 and 6. Then generate ten-thousand numbers between 1 and 6. Then calculate the number of 1 that has appeared, the number of 2 that has appeared, and so on. The final output must be on a dialog box (using JOptionPane). The process must be looped until the user decides to quit. The output format should like the following:
*****************************************
The dice has been rolled ten-thousand times, here is the statistics
The number of 1s appeared is 2000
The number of 2s appeared is 2000
The number of 3s appeared is 2000
The number of 4s appeared is 2000
The number of 5s appeared is 1000
The number of 6s appeared is 1000
Do you want to try again (Y/N)?:
*********************************************
This is what I have so far. I can get it to roll the die 10,000 times, but i cant figure out how to get the program to count the total for each number rolled and post it using JOptionPane.
import javax.swing.*;
public class Dice
{
public static void main(String[] args)
{
String choice="";
do
{
int total1=0, total2=0, total3=0, total4=0, total5=0, total6=0;
int[] A = new int[10000];
for(int i=0; i<A.length; i++)
A[i] = 1 + (int) (6*Math.random());
total1==
total2==
total3==
total4==
total5==
total6==
for(int i=0; i<A.length; i++)
System.out.println(A[i]);
}
{
JOptionPane.showMessageDialog(null,"The number of 1s appeared is" + total1, "The number of 2s appeared is" + total2, "The number of 3s appeared is" + total3, "The number of 4s appeared is" + total4, "The number of 5s appeared is" +total5, "The number of 6s appeared is" +total6);
choice = jOptionPane.showInputDialog("Recalculate? (Y=yes|N=no)");
}while (choice.equlas("Y"));
}