Question: Implement a coin tossing game using C++ functions that works as follows: 1. In main( ), ask the user for the number of times to

Implement a coin tossing game using C++ functions that works as follows:

1. In main( ), ask the user for the number of times to play (N) then call the function play( ) (explained below) to run the game.

2.Function play( ) receives N and:

a. Ask the user to guess the next coin flip outcome (h for head, t for tail).

b. If the user enters anything else than h or t, ask her again until a valid input is entered.

c. Implement and call function flipCoin( ) to get the outcome of the next coin flip. The function randomly returns h or t.

d. If the flip coin outcome matches the users guess, give her one point. If not, subtract one point. e. After repeating this process N times, the function returns (to main) the total number of points earned by the user (it may be negative).

f. Remember to initialize the point counter to zero at the beginning of the function.

3. Once back in main( ), print the user points and ask the user whether she wishes to play again. If yes, repeat the process from 1.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!