Question: I need help correcting my code, I got a error on my output and need help correcting it. The task of the project is posted
I need help correcting my code, I got a error on my output and need help correcting it. The task of the project is posted down below.
import java.util.Scanner; import java.util.Random;
public class GameOfPigs { public static void main(final String[] args) { int Score = 0; int Total = 0; int computerScore = 0; int subtotal = 0; int humanRoll, computerRoll; final Scanner keyboard = new Scanner(System.in); final Random rand = new Random(); char choice = '1'; String input; System.out.println("Welcome to the game of Pig! ");
while (computerScore = 100) { System.out.println("YOU WIN!"); } while (subtotal >= 100) { System.out.println("THE COMPUTER WINS!"); } } }



![static void main(final String[] args) { int Score = 0; int Total](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f4f0f35e3b0_49866f4f0f2b2c19.jpg)


Introduction One more practice with loops. This program will be a bit more involved that the previous For this program, you will create a simulation of the dice game Pig The objective of the game is for players to gain 100 points before their opponents, further details will be discussed in the tasks In this case the opponent will be the computer Task 1 This game requires two 6-sided dice. You will need to simulate these dice with a random number generator. The two dice (random number generators must: Produce values between 1-6 Have a seed of 140L and 340L, respectively for die one and die two (for testing purposes) Task 2 Now that you have your dice, we can go over the rules you will be playing by Rules: For each turn, the players will take turns rolling the two dice f a 1 doesn't appear on either dice, the values are added to the player's total They then have the choice to roll again (choice 0) or pass the turn to the other player (choice 1). f a 1 appears on one of the dice, the player gets no points added to their total for that entire turn and it becomes the other player's turn to roll (points earned on previous turns will still be present in their totals). If a player rolls both 1s, the player's turn is over and their total is reset to 0 You will need one more random number generator that will determine if the computer(0) or player(1) will go first. This will also be used to simulate the computer's choice to either roll again or pass the turn over. The seed for this generator will be 140L. Assume valid input from the user. Output should begin with the statement "Welcome of the Game of Pigs' All following user prompts should look similar to Your turn current points 0) You rolled 3 and 2, points earned this turn:5 Press 0 to roll again or 1 to start computer's turn. And all computer prompts should look like Computer's turn (current points 0) Computer rolled 1 and 4 no points earned and your turn They announce which player's turn and current points. Then numbers that were rolled by what player followed by if points earned, display total points earned for that turn (see the user's prompt 2nd line) if a one was rolled, announce no points earned and the next player's turn (see computer prompt 2nd line) if both are ones, use display message "/whichever player rolled two ones, points reset and /opponent's turn Introduction One more practice with loops. This program will be a bit more involved that the previous For this program, you will create a simulation of the dice game Pig The objective of the game is for players to gain 100 points before their opponents, further details will be discussed in the tasks In this case the opponent will be the computer Task 1 This game requires two 6-sided dice. You will need to simulate these dice with a random number generator. The two dice (random number generators must: Produce values between 1-6 Have a seed of 140L and 340L, respectively for die one and die two (for testing purposes) Task 2 Now that you have your dice, we can go over the rules you will be playing by Rules: For each turn, the players will take turns rolling the two dice f a 1 doesn't appear on either dice, the values are added to the player's total They then have the choice to roll again (choice 0) or pass the turn to the other player (choice 1). f a 1 appears on one of the dice, the player gets no points added to their total for that entire turn and it becomes the other player's turn to roll (points earned on previous turns will still be present in their totals). If a player rolls both 1s, the player's turn is over and their total is reset to 0 You will need one more random number generator that will determine if the computer(0) or player(1) will go first. This will also be used to simulate the computer's choice to either roll again or pass the turn over. The seed for this generator will be 140L. Assume valid input from the user. Output should begin with the statement "Welcome of the Game of Pigs' All following user prompts should look similar to Your turn current points 0) You rolled 3 and 2, points earned this turn:5 Press 0 to roll again or 1 to start computer's turn. And all computer prompts should look like Computer's turn (current points 0) Computer rolled 1 and 4 no points earned and your turn They announce which player's turn and current points. Then numbers that were rolled by what player followed by if points earned, display total points earned for that turn (see the user's prompt 2nd line) if a one was rolled, announce no points earned and the next player's turn (see computer prompt 2nd line) if both are ones, use display message "/whichever player rolled two ones, points reset and /opponent's turn
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
