CSC 172 - Intro to Algorithms and Data Structures

Dr. R. M. Siegfried

Assignment #2 - Simulating A Series Of Dice Games

Due - Wednesday, February 12, 2014

Last time, we wrote a program to simulate a game of craps and tell the user whether (s)he won lost. You can refer to the assignment by clicking here.

Rewrite the program by adding a loop so that the program plays 10,000 games and add counters so the program can count how many games the player win and how many games the player loses. At the end, compute the probability of winning (Wins/(Wins + Losses) and output this values as well as the actual number of wins and losses. Also, print who is oing to win the most, you or the house?

Make sure that the program is well-organized, documented and properly divided into separated methods.

NB: to generate a random number x, where 0 ≤ x < 1, use x = Math.random(); Then multiplying by 6 and add 1 to get a roll of the die. Use it twice to get the roll of two dice.

[Back to the Assignment Index]