Question: The following code contains a logic error: Examine the code and describe a case in which the code would print something that is untrue about
The following code contains a logic error:

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.
Scanner console = new Scanner (System.in); System.out.print ("Type a number: "); int number console.nextInt (); if (number % 2 0) { %3D3D if (number % 3 0) { %3D3D System.out.println ("Divisible by 6."); } else { System.out.println ("Odd."); }
Step by Step Solution
3.40 Rating (169 Votes )
There are 3 Steps involved in it
The code incorrectly prints that even numbers not divisible by 3 are odd ... View full answer
Get step-by-step solutions from verified subject matter experts
