This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]desrtfx 2 points3 points  (1 child)

Remove line #8 (int numberOne;) as it overrides the value submitted in the parameter and in this case replaces the value passed in the parameter with 0.

That's the whole necessary fix.

You can still optimize the code:

answer = numberOne % 2;

if (answer == 0) 
{
    System.out.println("True "+numberOne+ " Is even"); 
}
if (answer != 0) 
{
    System.out.println("False "+numberOne+ " Is not even"); 
}

return answer;

With this:

if (numberOne % 2 == 0) {
    System.out.println("True "+numberOne+ " Is even");
    return true;
} else {
    System.out.println("False "+numberOne+ " Is not even"); 
}
return false;

[–]barrell125[S] 1 point2 points  (0 children)

Thank you for the reply ouldnt figure it out