Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

NOTE: C++ IN MICROSOFT VISUAL STUDIO Write a program that has a function prototype before main and an implementation of the function after main. The

NOTE: C++ IN MICROSOFT VISUAL STUDIO

Write a program that has a function prototype before main and an implementation of the function after main. The function to be implemented is a coin toss simulation using the random number generator. The function should return 1 or true 50% of the time and 0 or false 50% of the time. Use srand and the system time to make the program run differently each time. (srand(time(NULL));). Keep track of the number of head and tails for 10, 100, 1000, 10,000, 100,000 and 1,000,000 trials. Output the number of heads and tails and number of each as a percentage of the total. Notice that the more trials the more accurate your simulation becomes.

Example Program Session:

Trials: 10 Head count: 6 Percent Heads 60.00 Tail Count: 4 Percent Tails 40.00 
Trials: 100 Head count: 57 Percent Heads 57.00 Tail Count: 43 Percent Tails 43.00 
Trials: 1000 Head count: 460 Percent Heads 46.00 Tail Count: 540 Percent Tails 54.00 
Trials: 10000 Head count: 4983 Percent Heads 49.83 Tail Count: 5017 Percent Tails 50.17 
Trials: 100000 Head count: 50105 Percent Heads 50.10 Tail Count: 49895 Percent Tails 49.90 
Trials: 1000000 Head count: 500135 Percent Heads 50.01 Tail Count: 499865 Percent Tails 49.99 
Try Again (1) Exit (0)1 
Trials: 10 Head count: 2 Percent Heads 20.00 Tail Count: 8 Percent Tails 80.00 
Trials: 100 Head count: 43 Percent Heads 43.00 Tail Count: 57 Percent Tails 57.00 
Trials: 1000 Head count: 484 Percent Heads 48.40 Tail Count: 516 Percent Tails 51.60 
Trials: 10000 Head count: 5005 Percent Heads 50.05 Tail Count: 4995 Percent Tails 49.95 
Trials: 100000 Head count: 49881 Percent Heads 49.88 Tail Count: 50119 Percent Tails 50.12 
Trials: 1000000 
Head count: 499958 Percent Heads 50.00 Tail Count: 500042 Percent Tails 50.00 

Try Again (1) Exit (0)0

Press any key to continue . . .

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Database Principles Programming And Performance

Authors: Patrick O'Neil, Elizabeth O'Neil

2nd Edition

1558605800, 978-1558605800

More Books

Students also viewed these Databases questions

Question

Is conflict always bad?

Answered: 1 week ago