1import java.util.Scanner;
2
3class CheckEvenOdd
4{
5 public static void main(String args[])
6 {
7 int num;
8 System.out.println("Enter an Integer number:");
9
10 //The input provided by user is stored in num
11 Scanner input = new Scanner(System.in);
12 num = input.nextInt();
13
14 /* If number is divisible by 2 then it's an even number
15 * else odd number*/
16 if ( num % 2 == 0 )
17 System.out.println("Entered number is even");
18 else
19 System.out.println("Entered number is odd");
20 }
21}
1import java.util.Scanner;
2public class FindEvenOrOdd
3{
4 public static void main(String[] args)
5 {
6 int a;
7 Scanner sc = new Scanner(System.in);
8 System.out.println("Please enter a number to check even or odd: ");
9 a = sc.nextInt();
10 if(a % 2 == 0)
11 {
12 System.out.println("Entered number is an even number.");
13 }
14 else
15 {
16 System.out.println("Entered number is an odd number.");
17 }
18 sc.close();
19 }
20}
1import java.util.Scanner;
2public class evenOrOdd{
3
4 public static void main(String[] args){
5 Scanner in = new Scanner(System.in);
6 System.out.println("Please enter a non-negative number: ");
7 int x = in.nextInt();
8 if (x % 2 == 0)
9 {
10 System.out.println("The number is even");
11 }
12 else {
13 System.out.println("The number is odd");
14 }
15 }
16}
17
18