Question: Please write a Python program to let you or the user play the game of rolling a dice and winning/losing money. Initially, you have 100

Please write a Python program to let you or the user play the game of rolling a dice and winning/losing money. Initially, you have 100 dollars in your account. You place a bet to roll the dice. The game will be stopped immediately if your bet is zero. First, dealer would roll the dice and get a number from the function call random.randint(1, 6). Then, you would roll the dice and get a number from the function call random.randint(1, 6). Now, compare your number with the dealers number to see whether you would win or lose the bet. If you should lose, the bet would be deducted from your account. If you should win, the bet would be added to your account. If it is a tie, your account is not touched. Then, continue the game of putting your bet until your bet is zero. The game is to continue even when you have zero or negative amount of money in your account.

You must test your game program 3 times with at least 9 rounds for each game. The output of your test case #1 should look as follows including the data. You must also do test case #2 and test case #3 with different sets of data. Each test case or test run must begin with a welcome message, and must end with a thank-you message.

Welcome to the Rolling Dice Game of Dr. Simon Lin! must use your name

1 =============================================.

Now, you have 100 dollars to play the game.

2 =============================================.

Enter your bet to roll the dice (enter 0 to quit): 10

Dealer got 1 , and you got 5 .

You won 10 dollars. Now, you have 110 dollars.

3 =============================================.

Enter your bet to roll the dice (enter 0 to quit): 5

Dealer got 5 , and you got 3 .

You lost 5 dollars. Now, you have 105 dollars.

4 =============================================.

Enter your bet to roll the dice (enter 0 to quit): 30

Dealer got 3 , and you got 3 .

It's a tie. Now, you have 105 dollars.

5 =============================================.

Enter your bet to roll the dice (enter 0 to quit): 200

Dealer got 3 , and you got 4 .

You won 200 dollars. Now, you have 305 dollars.

6 =============================================.

Enter your bet to roll the dice (enter 0 to quit): 100

Dealer got 4 , and you got 1 .

You lost 100 dollars. Now, you have 205 dollars.

7 =============================================.

Enter your bet to roll the dice (enter 0 to quit): 205

Dealer got 2 , and you got 6 .

You won 205 dollars. Now, you have 410 dollars.

8 =============================================.

Enter your bet to roll the dice (enter 0 to quit): 400

Dealer got 3 , and you got 6 .

You won 400 dollars. Now, you have 810 dollars.

9 =============================================.

Enter your bet to roll the dice (enter 0 to quit): 500

Dealer got 4 , and you got 1 .

You lost 500 dollars. Now, you have 310 dollars.

10 =============================================.

Enter your bet to roll the dice (enter 0 to quit): 310

Dealer got 6 , and you got 2 .

You lost 310 dollars. Now, you have 0 dollars.

11 =============================================.

Enter your bet to roll the dice (enter 0 to quit): 10

Dealer got 3 , and you got 6 .

You won 10 dollars. Now, you have 10 dollars.

12 =============================================.

Enter your bet to roll the dice (enter 0 to quit): 40

Dealer got 3 , and you got 1 .

You lost 40 dollars. Now, you have -30 dollars.

13 =============================================.

Enter your bet to roll the dice (enter 0 to quit): 0

14 =============================================.

Thank you for playing the Rolling Dice Game of Dr. Simon Lin! must use your name

15 =============================================.

You may use the following framework to complete your game program.

#---------------------------------------------------------------------------------------------------------------.

# Author: Dr. Simon Lin # must use your name

# Date: 1/07/2021

# Purpose: CS119-PJ4: A game to roll the dice and earn/lose money with initial money of 100 dollars

# for you to start your game.

# MAIN PROGRAM: ============================================.

import random

n = 1 # line number for each separator line in sequence

print ("Welcome to the Rolling Dice Game of Dr. Simon Lin!" ) # must use your name

print(n,"=========================================================."); n+=1;

yourMoney = 100

print( "Now, you have ", yourMoney, "dollars to play the game.")

while True:

print(n,"=========================================================."); n+=1;

bet = int(input("Enter your bet to roll the dice (enter 0 to quit): ")) # get bet

# your statements

dealer = random.randint(1, 6) # dealer rolls the dice

you = random.randint(1, 6) # you roll the dice

print("Dealer got ", dealer, ", and you got ", you, "." )

# your statements

print("You lost " , bet, " dollars. Now, you have ", yourMoney, " dollars. ")

# your statements

print("It's a tie. Now, you have ", yourMoney, "dollars.")

# your statements

print( "You won. Now, you have ", yourMoney, "dollars.")

# your statements

# end of while True loop

print(n,"=========================================================."); n+=1;

print("Thank you for playing the Rolling Dice Game of Dr. Simon Lin!") # must use your name

print(n,"=========================================================."); n+=1;

x = input("Press Ctrl+Alt+PrtScn to get a snapshot of this console, then ENTER to exit: ")

# End of MAIN PROGRAM ==========================================.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!