Write a java program that simulates a game of dice. In this game, 3 players will take alternate turns rolling two dice. On each turn, they record the sum of the two dice and add this to their total. If a player rolls a doublet (both dice have the same value), then the player gets to roll again until the doublet disappears. After each turn (when both roll), the code checks the sum of each player and the first player to reach a total of 15 or more will win the first place. When a player surpasses 15 but with a doublet (both dice have the same value), the player still gets to roll again until the doublet disappears. The code then checks for the second and third place winners. The code will print out to the user the winners in order. If 2 or all the players hit the same sum, you can consider them all first place winners (for example, if player 1 and 2 hit the same sum that’s >= 15 and 3rd player hits a sum less than 15, then you can say 1st and 2nd players win first place and 3rd wins second place). The same rule applies to a tie for the 2nd place (for example, if player 1 hits the sum that’s >= 15 and player 2 and 3 hit the same sum less than 15, then you can say 1st player wins the first place and 2nd and 3rd players win the second place). For this question, loop(s) and conditionals

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Write a java program that simulates a game of dice. In this game, 3 players will take alternate
turns rolling two dice. On each turn, they record the sum of the two dice and add this to
their total. If a player rolls a doublet (both dice have the same value), then the player gets
to roll again until the doublet disappears.


After each turn (when both roll), the code checks the sum of each player and the first
player to reach a total of 15 or more will win the first place. When a player surpasses 15
but with a doublet (both dice have the same value), the player still gets to roll again until
the doublet disappears. The code then checks for the second and third place winners. The
code will print out to the user the winners in order.


If 2 or all the players hit the same sum, you can consider them all first place winners (for
example, if player 1 and 2 hit the same sum that’s >= 15 and 3rd player hits a sum less
than 15, then you can say 1st and 2nd players win first place and 3rd wins second place).
The same rule applies to a tie for the 2nd place (for example, if player 1 hits the sum that’s
>= 15 and player 2 and 3 hit the same sum less than 15, then you can say 1st player wins
the first place and 2nd and 3rd players win the second place).


For this question, loop(s) and conditionals 

The output should be as follow (note: no user input is required):
Player 1 rolls a 1 and a 1
Player 1 now has 2
Player 1 rolls a 6 and a 1
Player 1 now has 9
Player 2 rolls a 3 and a 2
Player 2 now has 5
Player 3 rolls a 5 and a 1
Player 3 now has 6
Player 1 rolls a 4 and a 3
Player 1 now has 16
Player 2 rolls a 6 and a 1
Player 2 now has 12
Player 3 rolls a 6 and a 5
Player 3 now has 17
Player 3 wins the first place with a total of 17
Player 1 wins the second place with a total of 16
Player 2 wins the third place with a total of 12
Transcribed Image Text:The output should be as follow (note: no user input is required): Player 1 rolls a 1 and a 1 Player 1 now has 2 Player 1 rolls a 6 and a 1 Player 1 now has 9 Player 2 rolls a 3 and a 2 Player 2 now has 5 Player 3 rolls a 5 and a 1 Player 3 now has 6 Player 1 rolls a 4 and a 3 Player 1 now has 16 Player 2 rolls a 6 and a 1 Player 2 now has 12 Player 3 rolls a 6 and a 5 Player 3 now has 17 Player 3 wins the first place with a total of 17 Player 1 wins the second place with a total of 16 Player 2 wins the third place with a total of 12
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education