Out of Lab Program 3
Craps Simulation
Due Tuesday March 19, at the start of lab
Assignment
Suppose that you are considering heading to
Las Vegas over Spring Break to play Craps. To
decide what your odds of winning are, you
are going to write a Java program. The program
should simulate 100,000 games of Craps and
then print out the results.
Rules of Craps
A game of Craps is played with two six-sided dice.
The dice are rolled. If you roll a 2, 3, or 12 on the
first roll, you lose. If you roll a 7 or 11 on the
first roll, you win. Otherwise, keep rolling until
you either get the same number as your first roll (you
win in this case) or you get a 7 (you lose in this case).
Desired Output
Craps Simulation
----------------
100000 games:
45000 wins
55000 losses
Probability of winning: 45.00%
Note: 45% is not the real probability of winning.
Required Classes
To solve this problem, you should use a
Driver class and a Craps class. One of the
methods in the Craps class should be a
boolean method called simulateOneGame.
This method should return true
if the game is won
and false if the game is lost. Hint: you
might want to take advantage of the Math.random()
method in order to simulate a die roll.
What to Submit
- A printout of Driver.java and Craps.java.
- A diskette with your Java code on it.
On Tuesday, March 19th, your program will
be tested as part of the in lab.
Grading
- The program simulates Craps correctly.
- The output format matches the output format above.
- The program is well commented.
- The program uses meaningful names.
- The program uses indentation and white space appropriately.
- The program uses classes appropriately.
Special Notes
You may work with one other person on this assignment. However,
that person must be in the same lab section as yourself.
If you work with a partner, just hand in one printout and
one diskette with both of your names on it.