Loading...
Loading...
Loading...
A canteen gives each order a token number. Even tokens collect food at counter A and odd tokens at counter B. For each token, print EVEN or ODD.
Write a method static boolean isEven(int n) that returns true when n is even. main reads the tokens and prints the word for each one.
EVEN or ODD for the i-th token.Example
Input
3 14 7 0
Output
EVEN ODD EVEN
14 is even, 7 is odd, and 0 is even.
Try the problem first. Open one hint at a time.
A number is even when it leaves no remainder after dividing by 2.
Return the comparison itself: return n % 2 == 0;
In main, run a loop t times; inside it, call isEven in an if.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor