Java program to find the given number is Even / Odd

Views: 107   

Java program which takes a number as input and prints the given number is Even / Odd


import java.util.Scanner;

public class IfConditionPositiveOrNegative {

    public static void main(String[] args) {
        System.out.println("Please enter a number:");

        Scanner in = new Scanner(System.in);
        int i = in.nextInt();
        in.close();

        if (i < 0) {
            System.out.println("Given number is -ve");

        } else {
            System.out.println("Given number is +ve");
        }

    }
}

Output:

Please enter a number:
22
Given number is +ve
On By