Loading...
Loading...
Loading...
At a canteen counter, tokens with an even number are served at window 1 and odd tokens at window 2. A test build of the token system also produces negative numbers, so the check must work for them too.
Read a token number and print Even or Odd.
Even or Odd.Example 1
Input
14
Output
Even
14 % 2 is 0, so it is even.
Example 2
Input
-7
Output
Odd
-7 is odd. Note that -7 % 2 is -1 in Java, not 1.
Try the problem first. Open one hint at a time.
A number is even when it leaves no remainder after dividing by 2.
For negative numbers % gives a negative remainder, so compare the remainder with 0, not with 1.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor