Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ language (how to finish with the given codes?) Use the following description of the game of dice to solve the attached puzzle. What are

C++ language (how to finish with the given codes?) Use the following description of the game of dice to solve the attached puzzle.

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.

One player plays until he wins or loses. The player tosses 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. The game ends as soon as a player wins or loses. A player wins, loses or defines his point on the first toss of the dice. A player who defines his point continues to toss the dice until he wins or loses.

A player who tosses 7 or 11 on the first toss wins. A player who tosses 2, 3 or 12 loses on the first toss. A player who tosses anything else defines his point and tosses until he tosses his point again and wins or tosses 7 and loses.

//random number includes

#include

#include

//standard includes

#include

#include

using namespace std;

int main()

{

default_random_engine e;

uniform_int_distribution u(1, 6);

// puzzle begins

int roll_count = 1;

int point = die_sum;

roll_count++;

int die1 = u(e);

int die2 = u(e);

die1 = u(e);

die2 = u(e);

int die_sum = die1 + die2;

die_sum = die1 + die2;

cout << "You rolled " << die_sum << " (" << die1 << " and " << die2 << ")"

<< " on roll " << roll_count << endl;

cout << "You rolled " << die_sum << " (" << die1 << " and " << die2 << ")"

<< " on roll " << roll_count << endl;

cout << "You win on the first roll";

cout << "You lose on the first roll";

cout << "You win on roll " << roll_count << endl;

cout << "You lose on roll " << roll_count << endl;

cout << "Your point is " << point << endl;

cout << "Roll again!" << endl;

do

else

else

else

if(die_sum == 2 || die_sum == 3 || die_sum == 12)

if (die_sum == 7 || die_sum == 11)

if (die_sum == 7)

while (die_sum != 7 && die_sum != point);

{}

{}

// puzzle ends

cout << endl;

system("pause");

return 0;

}

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

More Books

Students also viewed these Databases questions

Question

After you have finished reading this chapter, you will be able to

Answered: 1 week ago