Challenge: Even or Odd

Lab Java Beginner 10 points

Read a whole number and print whether it is even or odd.

Input

One whole number (it may be negative).

Output

<n> is even or <n> is odd

Example

Input

4

Output

4 is even
Sample input available Sample output available
Editor
Java

Hints

A number is even when n % 2 == 0.

For negative odd numbers, n % 2 is -1, so test == 0, not == 1.

Solution explanation

In Java -3 % 2 is -1, so checking n % 2 == 0 works for every number.

Show solution
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n % 2 == 0) {
            System.out.println(n + " is even");
        } else {
            System.out.println(n + " is odd");
        }
    }
}
Output
Answer
HOME LABS COMMUNITY DASHBOARD