COSC 120

Program Assignment # 2


DESCRIPTION: Develop a program that will play an interactive game of chance called craps. Here are the rules. A player rolls 2 dice. Each die has 6 faces. These faces contain 1, 2, 3, 4, 5 and 6 spots. After the dice have come to rest, the sum of the spots on the two upward faces is calculated. If the sum is 7 or 11 on the first throw, the player wins. If the sum is 2, 3, or 12 on the first throw (called 'craps'), the player loses (the house wins). If the sum is 4,5,6,8,9 or 10 on the first throw, then that sum becomes the player's 'point'. To win, you must continue rolling the dice until you make your point. The player loses by rolling a 7 before making the point.;

CLARIFICATION: Your program must play one or more games. The user will be given the opportunity to play again at the end of each game. You will use a random number generator(explained in class) to simulate the roll of the dice. The program will keep track of how many games the player wins and loses. The user must type in a menu choice, a single character for each menu item (lower or upper case should be allowed). There will be an opening message welcoming the user to craps. A small menu consisting of P to play R for the rules and Q for quit.

A player wins or a player loses will be given at the end of each game. You must use at least 4 procedures. Make one of them a true value returning function.

Sample run:

Please make a choice of the following
P------Play craps
R-----See rules
Q-----Quit game

choice>p

If you would like to roll now please input y
y<e>

you rolled a 6 and a 1 = 7
Hurray you won

Please make a choice of the following
P------Play craps
R-----See rules
Q-----Quit game

choice>P

If you would like to roll now please input y
y<e>

you rolled a 4 and a 5=9
your point to roll is 9

If you would like to roll now please input y
y<e>

you rolled a 6 and a 2 =8
If you would like to roll now please input y
y<e>

you rolled a 2 and a 1=3
If you would like to roll now please input y
y<e>

you rolled a 4 and a 3=7
Sorry you lose

Please make a choice of the following
P------Play craps
R-----See rules
Q-----Quit game

choice>r

Here are the rules. A player rolls 2 dice. Each die has 6 faces. These faces contain 1, 2, 3, 4, 5 and 6 spots. After the dice have come to rest, the sum of the spots on the two upward faces is calculated. If the sum is 7 or 11 on the first throw, the player wins. If the sum is 2, 3, or 12 on the first throw (called 'craps'), the player loses (the house wins). If the sum is 4,5,6,8,9 or 10 on the first throw, then that sum becomes the player's 'point'. To win, you must continue rolling the dice until you make your point. The player loses by rolling a 7 before making the point.;

Please make a choice of the following
P------Play craps
R-----See rules
Q-----Quit game

choice>q

Wow, you just broke even with 1 win and 1 loss.

NOTE: If the player has more loses than Too bad you only won 1 game and lost 7.
If the player has more wins than Hurray you won 3 games and lost 2.