(Game of Craps) Write an application that runs 1000 games of craps (Fig 6.9) and answers the following questions:

  1. How many games are won on the first roll, second roll, ..., twentieth roll, and after the twentieth roll?
  2. How many games are lost on the first roll, second roll, ..., twentieth roll, and after the twentieth roll?
  3. What are the chances of winnning at craps? [Note: You should discover that craps is one of the fairest casino games. What do you suppose this means?]
  4. What is the average length of a game of craps?
  5. Do the chances of winning improve with the length of the game?

First of all, we only need to make very minor changes to the existing craps program. I suggest the following:

Secondly, your simulation program should look something like this (pseudocode):

Create a craps game object
Create an array to track wins by length of game
Create an array to track losses by length of game
Repeat 1000 times:
play a game of craps
increment the wins (or losses) array based on
the length of the game
increment the total wins or loses
For each possible number of rolls (1 to 20+)
print number of wins and losses
Print overall winning percentage
Print average game length

My solution will be available here and here after the end of next week’s class.