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 sixsided 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 to
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 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 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 and respectively.
After these print statements, declare an int variable that will hold the number of times you roll snake eyes two s when using twosix sided die Create a loop to perform rolls using the third method. Increment the snake eyes variable if the result is 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 sixsided die is
The result of rolling a single twentysided die is
The result of rolling two sixsided dice is
The probability of rolling snake eyes is
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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
