Read everything before doing anything.
This program is an update to the program of Assignment 3. Changes are highlighted in yellow, as this sentence is. You will add functions to that code to make it do the following:
This program plays a simplified version of roulette. You start out with $100.00 (virtual dollars, of course!). The program repeatedly asks you if you wants to bet on Odd, Even, Zero, Quit, or get Help. The player may enter O, E, Z, Q, or H in either uppercase or lowercase. If the player enters an invalid character, you have to give an error message.
If you entered H, the program will display the instructions for you.
If you entered a bet type (E, O, or Z) the program will ask you how much you want to bet (integers only). Your bet must be greater than zero and less than or equal to the amount of money you have remaining. The program will continue to prompt you for a bet until you give a valid bet.
The program will then spin the wheel and generate and display a number from 0 to 36 inclusive. If you guessed correctly, you win the amount of your bet. If you guessed wrong, you lose the the amount of your bet. The zero is special–it doesn’t count as even or odd, so if you guessed Zero and a zero comes up, you win 35 times the amount of your bet.
After each bet, the program tells you how much money you have left and congratulates you if you win or consoles you if you lost.
If you lose all your money, the program stops; otherwise, it asks for a new bet.
When you decide to quit (or you run out of money), your program will show the number of times you won, the number of times you lost, and the amount of money you have left.
You will save the program in a file whose name is in the form lastname_firstname_roulette2.cpp. Thus, if your name is Arthur Fellig, your file should be named fellig_arthur_roulette2.cpp. If your file is not named properly, it will not be graded.
Your program must contain at least two functions. The first one must be named
showInstructions. It takes no parameters and returns no value.
This function will show the instructions for the game.
The second function must be named getBetAmount. It takes the
amount of money remaining as its single parameter and returns the amount
bet as an integer. This function takes care of all processing involved in
asking the player for the bet and determining that it is a valid number.
You may add other functions to aid in program modularization or readability if you wish.
Here is code for the loop assignment. You may use this as a starting point for your program if you wish.
Here’s a sample of output from a working program. Player’s input is shown in bold and dark red like this to help you see what the player has entered.
Your output does not have to look exactly like this, but your output must reflect the same information.
Welcome to roulette. You may bet on Even, Odd, or Zero If you bet on zero and win, you win 35 times the amount you bet. You can choose Q to quit the game. The game ends automatically if you run out of money. Bet on E)ven, O)dd, Z)ero, H)elp, or Q)uit > e Enter amount of bet $50 The wheel comes up 33 Sorry, you lose. You now have $50 Bet on E)ven, O)dd, Z)ero, H)elp, or Q)uit > o Enter amount of bet $25 The wheel comes up 2 Sorry, you lose. You now have $25 Bet on E)ven, O)dd, Z)ero, H)elp, or Q)uit > o Enter amount of bet $10 The wheel comes up 32 Sorry, you lose. You now have $15 Bet on E)ven, O)dd, Z)ero, H)elp, or Q)uit > o Enter amount of bet $-12 Bets must be greater than zero. Enter amount of bet $20 You may not bet more than you have ($15) Enter amount of bet $10 The wheel comes up 27 You win! You now have $25 Bet on E)ven, O)dd, Z)ero, H)elp, or Q)uit > z Enter amount of bet $25 The wheel comes up 35 Sorry, you lose. You now have $0 Your remaining money is $0 Number of wins: 1 Number of losses: 4 Thanks for playing. Press ENTER to quit.
Attach the .cpp file to an email and send it to the instructor. You must put the words CIT020 C++ Assignment Functions in the subject line of your email, or your program will not be graded.