Check the number is even or odd

This Java program checks if a number is even or odd. The modulo operator performs an integer division and returns the remainder.

import java.util.Scanner;

class EvenOrOdd {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int x;

		System.out.print("Enter a value for x: ");
		x = reader.nextInt();
		reader.close();

		if (x % 2 == 0) {
			System.out.print("Number " + x + " is even");
		} else {
			System.out.print("Number " + x + " is odd");
		}
	}
}
Output
Enter a value for x: 6 
Number 6 is even