Question: Write a guessing game. 1-The user begins with 0 points. 2-The computer will roll a digital six-sided die and flip a digital two-sided coin. 3-The

Write a guessing game.

1-The user begins with 0 points.

2-The computer will roll a digital six-sided die and flip a digital two-sided coin.

3-The user must guess the number on the die (1,2,3,4,5, or 6) and the side the coin has landed on (H for heads or T for tails).

4-The roll and flip result are revealed.

5-If the user was right, s/he wins 10 new points. If the user was wrong, s/h loses 1 point.

6-The user is asked whether to continue the game. If so, the program goes back to step 2.

In writing your program, you should define at least the following functions:

-rollAndFlip (. . .) - called by main ()

Computes the outcome of a random die roll and coin flip

. userInput (. . .) called by main ()

Reads user input

It is your job to determine the inputs and outputs for each function you write, making sure to fulfill the specifications written above.

In this lab you must:

-use the srand () and the rand () functions

-create and use at least one call-by-reference function;

Example execution

>./guessingGame.out

Guess a (6 sided) die roll and a coin flip: 3h

Incorrect! Die roll was 5, coin flip was H.

Total points: -1

Do you want to try again? (Y/N) Y

Guess a (6-sided) die roll and a coin flip: 1 H

Incorrect! Die roll was 2, coin flip was T.

Total points: -2

Do you want to try again? (Y/N) Y

Guess a (6 sided) die roll and a coin flip: 5 T

Correct! Die roll was 5, coin flip was T.

Total points: 8

Do you want to try again? (Y/N) N

Goodbye. Thanks for playing!

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!