Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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 rand() 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 rand() generates double-type

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

1 54 56

2 46 49

3 51 52

4 45 48

5 55 41

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

What do you mean by Dividend ?

Answered: 1 week ago

Question

What is database?

Answered: 1 week ago

Question

What are Mergers ?

Answered: 1 week ago