FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 224   



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


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News