WAP to take a number as input and check if it is even or odd.

import java.util.*; public class T4 { public static void main(String[] args) { int n; Scanner sc = new Scanner(System.in); System.out.print("Enter number to find odd or even : "); n = sc.nextInt(); if (n % 2 == 0) { System.out.println(n + " is a even number."); } else { System.out.println(n + " is a odd number."); } } } Copy Code
Expected Output:
Input: 4
Output:
4 is an even number.

Input: 7
Output:
7 is an odd number.