Java Program To Check The Given Number is Even or Odd


package com.java2study;

import java.util.Scanner;

public class EvenOddDemo {


public static void main(String[] args) {
// accept input from user we need to call Scanner classes
Scanner scanner = new Scanner(System.in);
System.out.println("Enter A Number To check Even Or Odd:");
//Store the numeric value to number
int number = scanner.nextInt();
if(number%2 == 0){
System.out.println("The Given Number is Even Number");
}else{
System.out.println("The Given Number Is Odd Number");
}
}

}

output


Enter A Number To check Even Or Odd:
0
The Given Number is Even Number
--------------------------------
Enter A Number To check Even Or Odd:
1
The Given Number Is Odd Number

--------------------------------
Enter A Number To check Even Or Odd:
1
The Given Number Is Odd Number

No comments:

Post a Comment