Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Write a function that plays a game of craps. The function declares the random engine and the uniform distribution as static local variables. The

C++

Write a function that plays a game of craps. The function declares the random engine and the uniform distribution as static local variables. The function has 2 reference parameters

1) the number of times the player rolled the dice

2) the sum of the dice if the player won or lost on the first roll or

the player's point if the player won or lost on a succeeding roll.

The function returns true if the player won the game and false if the player lost the game.

Write a program that invokes the previously defined function N times where N is a very large number. The program counts the number of times that each dice sum wins and the number of times that each dice sum loses. I defined the function so that 2, 3, and 12 always lose and never, 7 and 11 always win and never lose; and 4, 5, 6, 8, 9, and 10 sometimes win and some times lose.

What are dice or what is a die the singular form of dice? A die is a cube of some hard, durable material, usually white in color. On each face of a die are a number of spots, usually black in color, arranged symmetrically on the face, each face having a different number of spots, ranging in number from one to six.

The Game of Craps

One player plays until he wins or loses. The player rolls a pair of dice on the ground and counts the number of spots on the upper most faces of the dice. A player either wins or loses, as craps allows no tie games. A player wins, loses or defines his point on the first roll of the dice. A player who defines his point continues to roll the dice until he wins or loses. A player who rolls 7 or 11 on the first roll wins. A player who rolls 2, 3 or 12 loses on the first roll. A player who rolls anything else - 4, 5, 6, 8, 9, 10, or 12 - defines his point and rolls until he rolls his point again and wins or rolls 7 and loses.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Put Your Data To Work 52 Tips And Techniques For Effectively Managing Your Database

Authors: Wes Trochlil

1st Edition

0880343079, 978-0880343077

More Books

Students also viewed these Databases questions