Question: Program 2: Pig (dice game) Program DUE: Tuesday, November 6 (by 11:50 pm) Pig is a dice game with the following rules: Two players race

 Program 2: Pig (dice game) Program DUE: Tuesday, November 6 (by

Program 2: Pig (dice game) Program DUE: Tuesday, November 6 (by 11:50 pm) Pig is a dice game with the following rules: Two players race to reach 100 points. Each turn, a player repeatedly rolls a die until either a 1 is rolled or the player holds and scores the sum of the rolls (i.e.the turn tota). At any time during a player's turn, the player is faced with two decisions: .roll-If the player rolls a o 1:the player scores nothing and it becomes the opponent's turn. o 2-6: the number is added to the player's turn totaland the player's turn continues. . hold The turn total is added to the player's score and it becomes the opponent's turn. The first player to score 100 or more points wins. For example, the first player, Ann, begins a turn with a roll of 5. Ann could hold and score 5 points, but chooses to roll again. Ann rolls a 2, and could hold with a turn total of 7 points, but chooses to roll again. Ann rolls a 1, and must end her turn without scoring. The next player, Bob, rolls the sequence 4-5-3-5-5, after which he chooses to hold, and adds his turn total of 22 points to his score Write a C++ program in which the computer will play the user in a game of Pig. A key decision to build strategy for the computer player is how large a turntotal should be risked to possibly get an even larger total. Use "hold at 20 strategy for your computer player (unless holding will win the game).(This will maximize the expected number of points per turn, though it does not maximize the expected probability of winning.) Include a welcome message/directions when the program first runs. After the welcome message, include a prompt that asks them to hit any key when they are ready to go on. Clear the screen using the command: system ("cls") o o Include appropriate user feedback, helpful prompts, output each dice roll, the final score gain, and the score at the end of each turn for the players, label output, be creativel MAKE THE GAME FUNI Include error checking on the input (only check for valid values, not invalid data type). Print an error message and allow the user to re-enter the input again. Make your code self-documenting, using appropriate indentation, style, and comments. After the game is over, ask the player if they want to play again. o o o Good Luck

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!