Question: The language is Java. Create a program called UnluckyRed which simulates 2 players playing the following game: A bag contains 2 red marbles and 9

Create a program called UnluckyRed which simulates 2 players playing the following game: A bag contains 2 red marbles and 9 green marbles. A player blindly picks one marble from the bag and returns the marble to the bag. If the selected marble is green, the player rolls 2 dice and adds the total face value of the dice to their score. If they roll a double (i.e. the face values are the same), the player's total score remains unchanged (i.e. a 0 score for that round). The player then picks a marble from the bag again, rolling again if a green marble is picked, and so on. The player's turn is finished when he picks a red marble. For example: Player 1 picks a green marble, rolls 4 and 3, picks a green marble again and rolls 2 and 2, picks a green marble again and rolls 2 and 5, then picks a red marble. Player 1 scores 14. Player 2 picks a green marble and rolls 6 and 4, then picks a red marble. Player 2 scores 10. Player 1 wins. Sample output 1: Player 1: 14 Player 2: 10 Player 1 wins Sample output 2: Player 1: 7 Player 2: 7 Tie Notes Use integers to represent the colors, considering the amount marbles for each color Your solution must include a method named displayWinner that accepts the player scores as parameters and does not have a return value. The winning roll must be determined by using Math or Integer utility method
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
