Java program to find if the given number is positive or negative

Read a number from the user using the Scanner class's method. check whether the given number is greater, lesser or, equal to 0. If it is greater given number is positive if the lesser given number is negative. the else given number is neither positive or negative.


import java.util.Scanner;

public class PositiveOrNegative {
   public static void main(String args[]){
      int num;
      System.out.println("Enter a number ::");
      Scanner sc = new Scanner(;
      num = sc.nextInt();

      if (num > 0){
         System.out.println("Given number is a positive integer");
      } else if(num < 0){
         System.out.println("Given number is a negative integer");
      } else {
         System.out.println("Given number is neither positive nor negative integer");

Output 1

Enter a number ::
Given number is a positive integer

Output 2

Enter a number ::
Given number is a negative integer
karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know