Reference no: EM133695009
The program:
You will write a simple dice game. The game starts by giving the player $250. The game prompts the player for the amount they want to bet and the sum of two randomly rolled die. If the player guess the sum correctly, the player wins some money based on the rules below. If the player guesses wrong, the player loses the amount that was bet. The game repeats until either the player runs out of money or the player chooses to stop playing.
Here are the rules for winning and losing.
If the guess matches the sum of the die and the two die have the same value, the winning is four times the bet. For example, if the player bet $100 and the player guesses four as the sum and first dice is two and second dice is two, then the player is awarded $400, which is twice the bet of $100.
If the guess matches the sum of the dice but the two die have different values, then the winning amount is the same as the bet.
If the player guesses the sum incorrectly, he loses the amount equal to the bet.
Input validation:
Make sure the player does not bet more than they have or a negative amount. If the amount is negative or greater than the amount they have, ask the player to reenter the bet.
Make sure the player types Y, y, N or n when prompted to continue the game. If the player enters anything else, the game should ask the player to reenter the answer.