Write a Java application which tests the random number generation abilities of J
ID: 3655085 • Letter: W
Question
Write a Java application which tests the random number generation abilities of Java. Random number generation is explained below.Your application should simulate rolling a pair of dice some number of times. Use a JOptionPane to ask the user how many times the dice should be rolled. Each dice roll can be a value between 1 and 6, so rolling 2 dice will result in values between 2 and 12. You need to generate a random number between 1 and 6 to simulate rolling each dice. Keep track of the result of each roll using an array that is indexed by the sumExplanation / Answer
FOLLOW THIS
import java.util.Random;public class Dice
{
Random diceGenerator = new Random();
int roll dice1, dice2, diceTotal, diceRoll;
int[] diceRecord = new int[6];
public void diceRoll()
{
for(roll = 1; roll DICETEST
import javax.swing.JOptionPane;
import javax.swing.JTextArea;
public class DiceTest
{
public static void main(String args[])
{
int choice;
choice = JOptionPane.displayOptionDialog(null, "Dice Roll Game. Would You Like To Play ",
"Dice",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE, null,null,null);
if(choice == JOptionPane.NO_OPTION)
{
System.EXIT(0);
}
Dice test = new Dice();
String output = "Number Of Rolls " + " Dice1 Output " + " Dice2 Output " + " Sum Of Dices ";
JTextArea area = new JTextArea( );
area.setText( output );
JOptionPane.displayMessageDialog( null, area, "Dice Generator",
JOptionPane.INFORMATION_MESSAGE );
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.