
Program 26
C++
K. Dzwonkiewicz
CRAPS
This program will be a
simulation of tossing dice in the game “Craps”.
A player will ‘roll’ two
dice. Each die will have 6 faces {1-6
spots}. After the dice come to rest,
the sum of the spots on the face-up sides is calculated. If the sum is 7 or 11 the player wins at
this point and the game is over. If the
sum is 2, 3, or 12 on this first toss the game is over and person has crapped out
(so to speak). If the sum is 4, 5, 6,
8, 9 or 10 on the first throw this becomes the person’s ‘mark’. They now throw again trying to get the
‘mark’ back (any combination is O.K.).
The player can now lose by getting 7 on these subsequent throws.
Sample
run…
Player rolls: 6 + 5 = 11
WINNER

Sample
run…
Player rolls: 6 + 6 = 12
YOU LOSE
Sample run…
Player rolls: 4 + 6 = 10
Point is 10
New roll: 2 + 4 = 6
New roll: 6 + 5 = 11
New roll: 3 + 3 = 6
New roll: 6 + 4 = 10
WINNER
Sample
run…
Player rolls: 1 + = 4
Point is 4
New roll: 1 + 4 = 5
New roll: 5 + 4 = 9
New roll: 5 + 2 = 7
YOU LOSE
HINT: See bonus 16 for help with the random