Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1- Write a program that simulates a game of dice. In this game, 3 players will take alternate turns rolling two dice. On each

1- Write a program that simulates a game of dice. In this game, 3 players will take alternate turns rolling

1- Write a 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. After each turn (when the 3 players roll), the code checks the sum of each player and the player to reach a total of 15 or more will win the first place and the game stops. 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). For this question, loop(s) and conditionals should be used otherwise you will lose marks. Don't hardcode the output otherwise marks will be deducted. 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 21 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

Step by Step Solution

3.46 Rating (153 Votes )

There are 3 Steps involved in it

Step: 1

python import random Define the number of players and the winning score numplayers 3 winningscore 15 Initialize player scores and turn counter playerscores 0 numplayers turn 0 Simulate the game until ... 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

Java Programming

Authors: Joyce Farrell

9th edition

1337397075, 978-1337397070

More Books

Students also viewed these Programming questions

Question

Under what circumstances will this change?

Answered: 1 week ago

Question

What other characters in the story have an opposite sequence of

Answered: 1 week ago