Question: Problem A: Flipping a Fair Coin Write a C++ program that simulates flipping a fair coin. Your program should do the following: 1. Ask the


Problem A: Flipping a Fair Coin Write a C++ program that simulates flipping a fair coin. Your program should do the following: 1. Ask the user to input a random seed (of type int), and call srand with that input number as its argument. That is, right after the variable declarations in your program you should have the lines cout Input the random seed cin seed; srand (seed) 2. Ask the user to input a difference value d, which should be an int 3. Uses the cmath function rando to generate a random number that is either 0 or 1. A 0 corresponds to a tail, and 1 to a head, and both possibilities should be equally likely. Repeat this process 100 times, counting the number of heads. Note that ran generates double-type d0 random numbers from 0 to 1 (inclusive), with all numbers being equally probable. Your task is to convert the generated number to 0 or 1, maintaining the equally probable property 4. Repeat Step 3 (i.e., generate another 100 random numbers) and count the number of heads in those 100 flips. 5. If the differences in the counts from Steps 3 and 4 is greater than or equal to the user input difference d, then stop. Otherwise repeat Steps 3 and 4 and check if the difference of the counts of these new samples is greater than or equal to d. If it is, stop. Continue this process until the difference in the counts is greater than or equal to d, or Steps 3 and 4 have been repeated 8 times Here is an example run: Input the random seed 346 Input the difference 8 Set 1 Set 2 54 56 46 49 52 51 45 4 8 55 41 Test your program a variety of times to make sure its answers are correct, as best you can tell. When you have written, tested, and corrected your solution, save your file as kusername> 3A.cpp, where you replace Kusername with your U of Musername. Submission information is given after Problem B. As usual, be diligent in following this naming convention
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
