Hold-at-20 Turn Pig is a folk jeopardy dice game with simple rules: Two players race to reach 100 points. Each turn, a player repeatedly rolls a die until either a 1 ("pig") is rolled or the player holds and scores the sum of rolls (i.e. the turn total). 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 26: the number is added to the player's turn total and the player's turn continues. hold - The turn total is added to the player's score and it becomes the opponent's turn. Problem: Simulate a single turn of Pig where a player rolls until a 1 ("pig") is rolled, or the turn total is greater than or equal to 20. Input Format: (no input) Output Format: • For each roll, print a line with "Roll: " and the random die roll value (1-6). • After a "pig" roll of 1, or a "hold", print a line with "Turn total: " followed by the turn total. In the case of a "pig", this turn total is 0.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Use Java to code this problem

Hold-at-20 Turn
Pig is a folk jeopardy dice game with simple rules: Two players race to reach 100 points. Each turn, a player repeatedly rolls a die until either a 1 ("pig") is rolled or the player holds and scores the sum of the
rolls (i.e. the turn total). 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 total and the player's turn continues.
• hold - The turn total is added to the player's score and it becomes the opponent's turn.
Problem: Simulate a single turn of Pig where a player rolls until a 1 ("pig") is rolled, or the turn total is greater than or equal to 20.
Input Format: (no input)
Output Format:
• For each roll, print a line with "Roll: " and the random die roll value (1-6).
• After a "pig" roll of 1, or a "hold", print a line with "Turn total: " followed by the turn total. In the case of a "pig", this turn total is 0.
Transcribed Image Text:Hold-at-20 Turn Pig is a folk jeopardy dice game with simple rules: Two players race to reach 100 points. Each turn, a player repeatedly rolls a die until either a 1 ("pig") is rolled or the player holds and scores the sum of the rolls (i.e. the turn total). 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 total and the player's turn continues. • hold - The turn total is added to the player's score and it becomes the opponent's turn. Problem: Simulate a single turn of Pig where a player rolls until a 1 ("pig") is rolled, or the turn total is greater than or equal to 20. Input Format: (no input) Output Format: • For each roll, print a line with "Roll: " and the random die roll value (1-6). • After a "pig" roll of 1, or a "hold", print a line with "Turn total: " followed by the turn total. In the case of a "pig", this turn total is 0.
Expert Solution
Overview

In this question we have to write a Java program to simulate the pig game which is known as hold at 20 turn 

Let's code and hope this helps if you have any queries utilize threaded questions feature.

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY