Question: Please help! I will make sure to give thumbs up!! IN JAVA PLEASE Problem 2. The game of Pig is a simple two-player dice game

Please help! I will make sure to give thumbs up!!

IN JAVA PLEASE

Problem 2. The game of Pig is a simple two-player dice game in which the first player to reach 100 or more points wins. Players take turns. On each turn, a player rolls a fair six-sided die:

  • If the player rolls a 1, then the player gets no new points and it becomes the other players turn.

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

ROLL AGAIN or HOLD. At this point, the sum of all rolls is added to the players score and it becomes the

other players turn.

In a class called H4P2, write a program that plays the game of Pig, where one player is a human and theother is the computer. When it is the humans turn, the program should show the score of both players and the previous roll. Allow the human to input R to roll again or H to hold.

The computer program should play according to the following rule: keep rolling when it is thecomputers turn until it has accumulated 20 or more points for that turn, then hold (of course, if the computer rolls a 1, then it is the humans turn again). If the computer wins or rolls a 1, then the turn ends immediately. Allow the human to roll first.

Make sure answer includes:

Winning condition

Pass condition

Keep rolling condition

I/O

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!