Question: In C++ THE PROBLEM : Stuck in the Mud is a dice game in which you roll 5 dice and try to accumulate as many

In C++

THE PROBLEM: Stuck in the Mud is a dice game in which you roll 5 dice and try to accumulate as many points as possible. If any of your rolled dice are a 2 or a 5, those dice become "stuck". The stuck dice do not get you any points and they are removed from play. You continue rolling dice until all 5 of your dice are stuck. Your job is to write a C++ program to simulate this game. When running the program, it should provide an output looking something like this:

Die#1 Die#2 Die#3 Die#4 Die#5 SUM

6_____4____4___ 3____ 1 _____18

3_____4____6____4____5_____ 35

6_____6____4____1___Stuck___52

3_____5____2____1___Stuck___56

6 ___Stuck_Stuck__1___Stuck __63

1___Stuck_Stuck___4___Stuck__68

5___Stuck_Stuck___3___Stuck__71

Stuck_Stuck_Stuck___1___Stuck__72

Stuck_Stuck_Stuck___2___Stuck__72

Stuck_Stuck_Stuck_Stuck__Stuck__72

Your final score: 72

Note: By using functions, your main() driver function should be fairly small (about 12-15 lines).

Suggestion: Create a global constant named STUCK and give it a value of -1. Use this constant STUCK throughout your program when setting a die to be stuck or checking if it is stuck.

For this project, you MUST use the following 4 functions:

Initialize the dice function: Simply set all of the dice to zero.

Roll the dice function: For each die that isn't stuck (has a value of -1), generate a random dice roll. If that new roll isn't a 2 or a 5, add it to the sum. This function should return the new sum back to the main program.

Display the dice function: On one line, display the contents of each die, plus the sum. If a die is stuck, display the word "Stuck" instead of its value. The format of the output should look like that shown on the previous page.

Game over function: This function should check each die to see if it is a 2 or a 5. If a die is a 2 or 5, the function should make it Stuck (change its value to -1). It should count how many dice are stuck. If all of the dice are stuck, it should return true. Otherwise, it returns false.

When developing the main driver algorithm, think about how each of these functions will be called.

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!