Question
Build a project called DieRolls and remember to include comments summarizing the program. 1. Declare the following six variables in your program: Six variables
Build a project called DieRolls and remember to include comments summarizing the program.
1. Declare the following six variables in your program: Six variables of type int that will hold the counts for each result of the die rolls: rolling a one, rolling a two, etc.
2. Use a for loop that will handle 10,000 rolls. On each iteration: Generate a random number from 1 to 6. This will represent the behavior of rolling a die. Depending on the random number generated, increment the corresponding count. For example, if a 1 is randomly generated, increment the count corresponding to ones.
3. After performing 10,000 rolls, display the counts and the percentage of counts out of the total rolls to the console. Format the percentages to two decimal places, and be careful about performing integer division.
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 total amount of ones rolled is 1634. The probability of rolling a one is 16.34%
The total amount of twos rolled is 1667. The probability of rolling a two is 16..67%.
The total amount of threes rolled is 1775. The probability of rolling a three is 17.75%.
The total amount of fours rolled is 1651. The probability of rolling a four is 16.51%.
The total amount of fives rolled is 1648. The probability of rolling a five is 16.48%.
The total amount of sixes rolled is 1625. The probability of rolling a six is 16.25%.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
ge interpolating polynomial we need to select vithin the range 100 K to 300 K Then wel...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started