Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

6. Explain the strengths of a dialectical approach.

Answered: 1 week ago