Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java 0 . The game of Pig is a simple two-player dice game in which the first player to reach 100 or more points wins.

Java

image text in transcribed

0 . 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 six-sided die: - If the player rolls a 1, then the player gets no new points and it becomes the other player's 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 player's score and it becomes the other player's turn. Write a program that plays the game of Pig, where one player is a human and the other is the computer. When it is the human's 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 the computer's turn until it has accumulated 20 or more points, then hold. If the computer wins or rolls a 1, then the turn ends immediately. Allow the human to roll first

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

25 Vba Macros For Data Analysis In Microsoft Excel

Authors: Klemens Nguyen

1st Edition

B0CNSXYMTC, 979-8868455629

More Books

Students also viewed these Databases questions

Question

What does Section 404 of the Sarbanes-Oxley Act require?

Answered: 1 week ago

Question

8. Describe how cultural spaces are formed.

Answered: 1 week ago