Java program to check if a number is odd or even: if a number is divisible by two then it is even, otherwise, it is odd. We use modulus operator to find remainder in our program. For an even number remainder will be zero when it is divided by two and will be one for an odd number.
public static void main(String args)
System.out.println("Enter an integer to check if it is odd or even");
Scanner in = new Scanner(System.in);
x = in.nextInt();
if (x % 2 == 0)
System.out.println("The number is even.");
System.out.println("The number is odd.");