Question: Write a program in C++ that plays a dice game with the user. /* Dice Game The game consists of 7 rounds. Each round consists

Write a program in C++ that plays a dice game with the user.

/* Dice Game The game consists of 7 rounds. Each round consists of the player's turn followed by the computer's turn. Each round is either won by the player, or won by the computer. The winner of the game is whoever wins the most rounds. The player's turn: The player throws three dice. The player's score for the turn is the largest value of the three dice. The player may choose to reject the throw and throw three dice again (but in this case the computer will throw four dice.) The new score is again the largest value of the three dice. Only the first throw may be rejected. The outcome of the second throw (if done) is the player's score for the turn. The computer's turn: The computer throws three or four dice. The computer throws four dice when the player threw twice. The computer's score for the turn is the largest value of the dice thrown. The winner of the round is whoever has the highest score. In the case of a tie, the computer wins the round. */

Example of how the output of the program should look like in C++

D:\Source\prog05dice>.\a.out

Round 1

Player's Turn: (hit enter)

You throw: 4, 4, 3

The maximum is 4

Do you wish to throw again? [Y or N] N

Computer's Turn:

Computer throws: 2, 4, 3

Computer's score is 4

Computer wins the round. human: 0. computer: 1

Round 2

Player's Turn: (hit enter)

You throw: 3, 5, 6

The maximum is 6

Do you wish to throw again? [Y or N] N

Computer's Turn:

Computer throws: 1, 3, 1

Computer's score is 3

Human wins the round. human: 1. computer: 1

Round 3

Player's Turn: (hit enter)

You throw: 5, 3, 4

The maximum is 5

Do you wish to throw again? [Y or N] Y

You throw: 6, 2, 5

Your final score is 6

Computer's Turn:

Computer throws: 4, 5, 4, 3

Computer's score is 5

Human wins the round. human: 2. computer: 1

Round 4

Player's Turn: (hit enter)

You throw: 4, 6, 4

The maximum is 6

Do you wish to throw again? [Y or N] n

Computer's Turn:

Computer throws: 2, 2, 3

Computer's score is 3

Human wins the round. human: 3. computer: 1

Round 5

Player's Turn: (hit enter)

You throw: 6, 5, 3

The maximum is 6

Do you wish to throw again? [Y or N] n

Computer's Turn:

Computer throws: 6, 4, 5

Computer's score is 6

Computer wins the round. human: 3. computer: 2

Round 6

Player's Turn: (hit enter)

You throw: 1, 4, 6

The maximum is 6

Do you wish to throw again? [Y or N] Y

You throw: 5, 4, 3

Your final score is 5

Computer's Turn:

Computer throws: 2, 3, 2, 4

Computer's score is 4

Human wins the round. human: 4. computer: 2

Round 7

Player's Turn: (hit enter)

You throw: 5, 2, 1

The maximum is 5

Do you wish to throw again? [Y or N] n

Computer's Turn:

Computer throws: 1, 6, 1

Computer's score is 6

Computer wins the round. human: 4. computer: 3

WINNER!! The human wins the game!

Please have code in C++

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!