Question
A simple game of chance Using a while loop write a simple coin flip game. ( C++) Specifics: The user starts with a bank of
A simple game of chance
Using a while loop write a simple coin flip game. ( C++)
Specifics:
The user starts with a bank of $10.00
It costs a dollar to play
A correct guess pays $2.00
The while loop is used for the game loop. It should ask if the user wants to play.
The while loop will check for a value of 'Y' or 'N'. You should also allow for lower case letters to be input.
You MUST prime the while loop by asking if the user wants to play before the loop starts.
You should output the bank before asking for a guess.
You should use the random number generator to generate a value of 0 and 1. A value of 0 = Heads (H), and a value of 1 = Tails (T);
Your program will take in a value of 'h' (Heads) or 't' (Tails) as the input value of the guess.
To determine if the user wins you will compare the users guess to the value generated by the random number generator.
Note that a conversion will have to take place to convert the number generated to a character.
The game should continue until the user indicates they do not want to play anymore. Your code should ask if the user wants to play again.
When the while loop ends you should thank the user for playing and output the bank.
A do-while loop is not a while loop. You MUST use a while loop.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started