Question
This program should simulate the roll of a single die (dice) (1-6) using the C++ random number functions. First ask the user how many times
This program should simulate the roll of a single die (dice) (1-6) using the C++ random number functions. First ask the user how many times they would like to have the die (dice) rolled. Next, have the program simulate the number of rolls of the die (dice) the user requested and keep track of which number the die (dice) landed on for each roll. At the end of the program print out a report showing how many times the die (dice) roll landed on each number and what percentage of the total times the die (dice) roll landed on each number. Do NOT use functions or arrays on this - use what I showed you during lecture, you should always listen during lecture to get the right techniques, if you forgot what I said during lecture look at the slides.
Input Validation: Do not allow the user to enter a number less than 1 as the number of times they would like to roll the dice. Your output should look similar to what is below
DICE ROLL STATISTICS
# Rolled # Times % Times
------ ------- --------
1 4 16.00%
2 3 12.00%
3 5 20.00%
4 7 28.00%
5 4 16.00%
6 2 8.00%
HINT: Put your sRand() function outside of your loop (remember what happened in class when we put it inside the loop!). Watch what happens if you put it inside loop and see if you can figure out why that happens. Make sure your program does not use the same random sequence each time you run it.
Regarding output: For the dice number and percentage of times rolled a setw(8) was used.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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