Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please correct my code so that for odd numbers such as 5 and -127, it returns odd. Currently, the code works for even numbers divisible
Please correct my code so that for odd numbers such as 5 and -127, it returns "odd." Currently, the code works for even numbers divisible by 6 and other even numbers not divisible by 6.
The following code contains a logic error. Examine the code and figure out the case(s) in which the code would print something that is untrue about the number that was entered. Then correct the logic error in the code. You should retain the original printed messages (and not add any new ones), but make them print at appropriate times such that the message printed is always a true statement about the integer typed. Revert Type your solution here: 1 Scanner console = new Scanner(System.in); 2 System.out.print("Type a number: "); 3 int number = console.nextInt(); 4 if (number % 2 == 0) { if (number % 6 == 0) { System.out.println("Divisible by 6."); 7 } else { 8 if (number % 2 == 1) {System.out.println("Odd."); 10 } 11 } 12}Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started