Problem #1: Write a program to simulate playing craps for $1 per game, where you gain $1 if you win and lose $1 if you lose the game. The program will ask the user for a starting amount (in dollars) and then keep playing until either you have doubled the starting amount or you have nothing left ($0). The final output of your program should state whether you have doubled your money (Sample Output #1) or are broke ($0) (Sample Output#2). Format the output of your program as shown below.

 

Sample Output#1:

How much money are you betting?

3

Start of Game#1

Game Won!

End of Game#1

Balance = $4

 

Start of Game#2

Game Won!

End of Game#2

Balance = $5

 

Start of Game#3

Game Won!

End of Game#3

Balance = $6

MONEY DOUBLED

 

 

Sample Output#2:

How much money are you betting?

3

Start of Game#1

Game Lost!

End of Game#1

Balance = $2

 

Start of Game#2

Game Lost!

End of Game#2

Balance = $1

 

Start of Game#3

Game Lost!

End of Game#3

Balance = $0

BROKE

 

 

 

Problem #2:

Your program has to implement a dice game which consists of rolling three six-sided dice.

Each game is played as below:

a)     The program will randomly generate a value, N from 1(inclusive) to 6(inclusive).

b)    The program rolls the dice. The program is allowed a maximum of five rolls.

c)     If, in a given roll (first or second or third or fourth or fifth), the value of N appears two or more times, the game has been won and the game ends.

d)    If the value of N does not appear two or more times in any of the five rolls (first, second, third, fourth and fifth), the game has been lost and the game ends.

The examples below illustrate the game as per the abovementioned rules:

Example #1:

N = 4 (randomly generated)

Roll #1:  Dice1 = 3            Dice2 = 2     Dice3 = 4 (4 appears only once. Go on the next roll)

Roll #2:  Dice1 = 5            Dice2 = 4     Dice3 = 4 (4 appears two or more times (twice). Game won. End of game)

 

Example #2:

N = 2 (randomly generated)

Roll #1:  Dice1 = 3            Dice2 = 2     Dice3 = 4 (2 appears only once. Go on the next roll)

Roll #2:  Dice1 = 5            Dice2 = 3     Dice3 = 3 (2 does not appear. Go to the next roll)

Roll #3:  Dice1 = 1            Dice2 = 4     Dice3 = 1 (2 does not appear. Go to the next roll)

Roll #4:  Dice1 = 3            Dice2 = 4     Dice3 = 5 (2 does not appear. Go to the next roll)

Roll #5:  Dice1 = 5            Dice2 = 2     Dice3 = 3 (2 appears only once. Game lost. End of game)

 

Example #3:

N = 3 (randomly generated)

Roll #1:  Dice1 = 5            Dice2 = 3     Dice3 = 5 (3 appears only once. Go to the next roll)

Roll #2:  Dice1 = 5            Dice2 = 4     Dice3 = 5 (3 does not appear. Go to the next roll)

Roll #3:  Dice1 = 3            Dice2 = 3     Dice3 = 3 (3 appears two or more (three) times. Very rare! Game won. End of game)

 

Your program must:

1)    Play this game 1000 times.

2)    Compute and print the total number of games won.

3)    Compute and print the total number of games lost.

 

 

Example runs of your program:

#1)

Total Games won = 331

Total Games lost = 669

 

#2)

Total Games won = 294

Total Games lost = 706

 

#3)

Total Games won = 326

Total Games lost = 674

 

#4)

Total Games won = 316

Total Games lost = 684