Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How to code that in java Round 1 Score: 0-0 player 1, it is your turn. You rolled a 6 . You have 6 points.

How to code that in java image text in transcribed
image text in transcribed
image text in transcribed
Round 1 Score: 0-0 player 1, it is your turn. You rolled a 6 . You have 6 points. Keep going? ( y) n. Score: 60 player 2, it is your turn. You rolled a 3. You have 3 points. keep going? (y) y You folled a 5. You have 8 points. Keep going? (y) n. Round 2 Score: 68 Player 1, it is your turn. You ro1led a 5 . You have 5 points. Keep going? (y) y You rolled a 6 . You have 11 points. Keep going? (y) n Score: 178 You will write a program in a class named DiceGame. To complete this program, you will need to use a Scanner (or TextI0) for user input, the Math. random() method to select a random number, and if-else statements (as Zou did in GuessNumber.java). In addition, you will need to use a for-loop (or while loop) to repeat a block a specified number of times, and a while loop for the rolling of the die. - The game will have two players. In my program, I identified them as Player 1 and Player 2. (You may use different names, as long as we can tell whose turn it is.) - The game will last three rounds, and each player gets one turn per round. - When a player's turn begins, print the current score and identify whose turn it is. - A player's turn continues until a 1 is rolled or until the player decides to stop and keep the points accumulated during their turn. - Select a random integer between 1 and 6 for the current die roll. - Report the value rolled. - If the player rolled a 1 , the turn is over with no points scored. Play: A new round begins. Player 1 rolls a single six-sided die. If they get a 1 , their turn is over. Otherwise, their roll is added to the number of points they've accumulated in the current round. After each roll, Player 1 can either stop and keep the points they've accumulated, or roll again to try and accumulate more points. If they ever roll a 17 their turn ends, they lose all the points they've accumulated this round, and Player 2 gets to start rolling the die

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

Students also viewed these Databases questions

Question

2. What do you believe is at the root of the problem?

Answered: 1 week ago