Question: 3. The following code contains a logic error: 1. Scanner console = new Scanner(System.in); 2. System.out.print(Type a number: ); 3. int number = console.nextInt(); 4.
3. The following code contains a logic error: 1. Scanner console = new Scanner(System.in); 2. System.out.print("Type a number: "); 3. int number = console.nextInt(); 4. if (number % 2 == 0) { 5. if (number % 3 == 0) { 6. System.out.println("Divisible by 6."); 7. } else { 8. System.out.println("Odd."); 9. } 10. } Examine the code and describe a case in which the code would print something that is untrue about the number that was entered. Explain why. Then correct the logic error in the code.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
