Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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 sum

Explanation / 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 );
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote