Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a C++ program that simulates rolling a fair eight-sided die. Your program should do the following: 1. In order to control the execution of
Write a C++ program that simulates rolling a fair eight-sided die. Your program should do the following: 1. In order to control the execution of this "ran dom program, you need to set up the random number generator so that it can repeat the sequence of numbers it generates - this will enable you (and us) to test your program. To accomplish this, your program will ask the user to input a number used as a seed (of type int) for the predefined random number generator rand, and call the random number seed function srand with that input number as its argument. Specifically, right after the variable declarations in your program you s sequence of statements: cout seed; srand (seed) Your program should then behave as follows 1. Ask the user input difference d as a double precision number 2. Generate the sum of a 100 rolls" of the eight (8)-sided fair die. Each value of rolling an 8-sided die to generate numbers (1 through 8) should be equally likely 3. Repeat step 2 4. Print the averages of the sums generated by the rolling the eight sided die in steps 2 and 3 above with two digits to the right of the decimal point. 5. Run 10 repetitions of steps 2, 3, and 4 above (following the correct order for this process is important), and after the 10 repetitions are completed, print out how many of them had their averages differ by more than the user input difference d . 6. The entire process (after setting the random seed) should be in a do-while continuation
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