Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

If the player rolls a 1, then the player gets no new points andit becomes the ot

ID: 3615689 • Letter: I

Question

If the player rolls a 1, then the player gets no new points andit becomes the other player's turn

If the player rolls 2 through 6, then he can either:

Roll again or

Hold, at this point the sum of all rolls is added to theplayer's score and it becomes the other player's turn.

Write a program that plays the game of Pig, where one player isa human and the other is the comptuer. When it is the human's turn,the program should show the score of both players and the previousroll. Allow the human to input "r" to roll again or "h" tohold.

The computer program should play according to the followingrule.

Keep rolling when it is the computer's turn until it hasaccumulated 20 or more points, then hold. If the computer wins orrolls a 1, then the turn ends immediately.

Allow the human to roll first. The following line of code can beused to generate a random number between 1 and 6 that cancorrespond to the dice roll.

int diceroll1 = (int) (Math.random() * 6) + 1

Explanation / Answer

please rate - thanks you didn't say when the game was over. #include #include using namespace std; int main() {int die,player1=0,player2=0,thisturn; bool hold; char rorh; srand(time(0)); while(player1