代写 game CSC 115 Program 2

CSC 115 Program 2
Topics: Conditional statements, while loop

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 dice. If the player guesses 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 sum matches the sum of the dice, and the two dice have the same value, the winning amount is twice the bet. For example, if the player bets $100, and the player guesses four as the sum, and first die is two and second die is two, then the player is awarded $200, which is twice the bet of $100.
• If the sum 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 wrong sum, he loses the amount equal to the bet.

Extra credits (1 point):
• 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.

Sample run (next page):


Welcome to Dice Game.
____
 /’ .\ _____
 /: \___\ / . /\
 \’ / . / /____/..\
 \/___/ ‘ ‘\ /
 ‘__’\/

You are given $ 250 to start.
You can’t play once you run out of money.
How much are you betting? 250
Rolling the dice…..
What is the sum of the two dice? 5
Die 1 is 3
Die 2 is 2
You win $ 250
Your current balance is $ 500
Do you want another game? Y/N: Y
How much are you betting? 100
What is the sum of the two dice? 4
Die 1 is 3
Die 2 is 5
You lost $ 100
Your current balance is $ 400
Do you want another game? Y/N: Y

How much are you betting? 100
Rolling the dice…..
What is the sum of the two dice? 10
Die 1 is 5
Die 2 is 5
You win $ 200
Your current balance is $ 600
Do you want another game? Y/N: Y

How much are you betting? 600
Rolling the dice…..
What is the sum of the two dice? 8
Your current balance is $ 0
Sorry, you are out of money.
See you later!