Starting from:

$30

HW 6 Problem Solution




Write a simulation of the "Craps" game.




Simulate a Six-Sided Die




Write a function to produce integers in the range 1 to 6 using the modulus operator (%) with `rand` function.




Simulate a Craps Game




Rules of Craps:

- A player rolls two dice. Each die has six faces.

- 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 roll, the player wins.

- If the sum is 2, 3 or 12 on the first roll (called "craps"), the player loses (i.e., the "house" wins).

- If the sum is 4, 5, 6, 8, 9 or 10 on the first roll, then that sum becomes the player's "point."

- To win, continue rolling until you "make your point."

- You lose by rolling a 7 before making the point.

- Allow player to repeat the game.

More products