Question: There are multiple errors in the following code segment. Some errors may keep the code from compiling, and some may make the program not run
There are multiple errors in the following code segment. Some errors may keep the code from compiling, and some may make the program not run as it is intended to (as is indicated in the included comments).
Identify the errors and create a comment to mark where they are in the code. Hover over the line that contains the error and click the comment button. Your comment will appear in the line below (it will not change the line numbers in the code).
In the comment, put the line number that contains the error and a brief explanation of what the error is.
NOTE: This is a section of code from a fully declared class, so for this exercise its okay that its missing the public static void main..., import Scanner, etc.

1 // This method gets a number from the user and prints messages depending 2 // on what number they put in 3 4 public static void pickNumber() { 5 6 7 Scanner sc = new Scanner(System.in); System.out.println("Please enter a number:"); int num = sc.nextInt(); 8 9 10 // If they guess a 13, they get a message 11 12 if(num == 13); { 13 14 System.out.println("13 is an unlucky number :( "); 15 } 16 17 // If they guess a 2, they get a message 18 19 if(num = 2) { 20 21 System.out.println("So close to the winning number!"); 22 } 23 24 // If they guess a 3, they win! // Print the winning messages 25 26 27 if (num = 3) 28 29 System.out.println("You guessed 3 !!!!"); System.out.println("You win the game!"); 30 31 32 33 sc.close(); // close the Scanner 34
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
