$29.99
CMPSC 201
Project 2
Worth 40 pts
For this project you are simulate a game using the concepts of the lottery problem from
Algorithms 3. Initially the user will enter the amount of money with which he/she can play (bet).
Each time the user chooses to play the lottery it will cost $100. Each time the user plays, he/she
will be prompted to enter from zero to 99 (including zero and 99) If the user’s number matches
randomly generated number exactly, the user wins $5000.00. If the user’s guess contains the
same digits as the randomly generated number, but they are in reverse order (e.g. 67 and 76), the
user will win $2000.00. If one digit of the user’s guess is in the randomly generated number, the
user should win $500.00. If the randomly generated number or the user’s guess is less than 10
treat the number as if it has 0 as the first digit (9 should be treated as 09). They user can
continue playing as long as he/she still has enough money to play again ($100) and wants to
continue playing.
Your program should employ a while loop to confirm that the user’s initial amount of
money is at least $100 and that each guess is greater than or equal to zero and less than 100.
Then your program should employ a do-while loop to allow the user to keep playing as long as
he/she wants and has at least $100. The guessed number and the randomly generated number
should be stored as an integer. The first and second digit of both the user’s guess and the
randomly generated number should be determined using a minimum number of arithmetic
operators. (At no time should the user’s guess or the randomly generated be stored as an
array or string). Your program should use an if-else if to determine how much the use wins
each time he/she plays. During each play the randomly generated number and the user’s guess
should be output.
Hint to test your program use a specific number rather than a randomly generated number to
compare the user’s guess. Then generate the number randomly after you have confirmed the
determined your if-else if works correctly.
Do not use any concepts beyond Chapter 5 of your textbook (e.g. arrays or programmer
built functions). Attach your source code file (*.cpp) to the appropriate drop box on
ANGEL and take the time to confirm your submission. Remember you will not receive any
credit for files not attached or submissions to incorrect drop box.