Question: Consider the following Java function, which is written incorrectly. Under what cases will the function print the correct answer, and when will it print an
Consider the following Java function, which is written incorrectly. Under what cases will the function print the correct answer, and when will it print an incorrect answer? What should be changed to fix the code? Can you think of a way to write the code correctly without any ifelse statements?
public void printNumOddint n int n int n
int count ;
if n
count ;
else if n
count ;
else if n
count ;
Systemout.printlncount of the numbers are odd.";
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
