Question: First, implement a method that will handle rolling a single six - sided die. This method will not take any arguments and will return an

First, implement a method that will handle rolling a single six-sided die. This method will not take any arguments and will return an int for the result rolled. To handle the roll, generate a random number from 1 to 6.
Next, implement a method that will handle rolling a single die with any number of sides. This method will take an int specifying the number of sides and will return an int for the result rolled. To handle the roll, generate a random number from 1 to the number of sides.
Next, implement a method that will handle rolling two dice with any number of sides. This method will take two int specifying the number of sides for each of the two die. This method will return an int for the sum of the results rolled. To handle the rolls, generate two random numbers from 1 to the number of sides for that die.
In the main method, write three print statements to display the result of calling each of the three methods. For the second and third methods, use the values (20) and (6,6), respectively.
After these print statements, declare an int variable that will hold the number of times you roll snake eyes (two 1s when using two-six sided die). Create a loop to perform 10000 rolls using the third method. Increment the snake eyes variable if the result is 2. After performing these rolls, print the probability of rolling snake eyes.
Examples: The following is an example program flow. Keep in mind that the die rolls are random, so the outputs will be slightly different each time you run the program.
The result of rolling a single six-sided die is 4
The result of rolling a single twenty-sided die is 8
The result of rolling two six-sided dice is 6
The probability of rolling snake eyes is 2.84%.
Criteria: Make sure you have the following in your program:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!