Assignment 3 Solution

$30.00 $24.90

Description

Write a program that simulates coin tossing and use the program to see if the coin gets heads half the time and gets tails half the time or if there is some bias. Use time(0) to seed your function.

Do this by running 20 tests where in each test the coin is tossed 100 times. Print out the number of heads seen and the number of tails seen at the end of each test which consisted of 100 tosses. The program should call a separate function flip that takes no arguments and returns a 0 for tails and a 1 for heads (you may use global variables for this IF you cannot figure out how to use static with the random number generator). You should use another function that is a pass by value function and you should use at least one more function that is pass by reference (See Figure 6.17). Do not use any global variables in the pass by value or pass by reference functions. After all 20 tests have been run, print out the summary of the differences seen between heads and tails. See the example output below. You do not need to create a class and you may do all of this in one main program.

Turn in pdfs of your test cases results by uploading them to T-Square (please no JPEG or PNG or word, upload a pdf doc for your test cases). Also in addition, upload the source code files (uncompiled) on or before the due date so your program may be tested. How your code is commented, how well you tested the program (just one test case or enough test cases to prove it works), any extra functionality, how you output your test results and details of program output will all be taken into consideration when grading your program. Your format of your code should look like that of the book. Note the comments in the book above every function explaining what that function does. You should have comments at the top that includes your name, the date, explains what the program does and comments above the functions explaining what they do in addition to some comments as needed on lines that explain what that line does.

How your code is commented, how good of a random number generator you used, how well you tested the program (just one test case or enough test cases to prove it works), any extra functionality, how you output your test results and details of program output will all be taken into consideration when grading your program. Your format of the source code should look like that of the book. Note the comments in the book above every function explaining what that function does. You should have comments at the top that explain what the program does and comments above the functions explaining what they do in addition to some comments as needed on lines that explain what that line does.