Computer Science, asked by shaw91325, 2 months ago

write a program to input a number and find it is Positive or negative (in java programming in basic terms) . ​

Answers

Answered by mauryapradeep76
1

{

public static void main(String[] args)

{

int n;

Scanner s = new Scanner(System.in);

System.out.print("Enter the number you want to check:");

n = s.nextInt();

if(n > 0)

{

System.out.println("The given number "+n+" is Positive");

}

else if(n < 0)

{

System.out.println("The given number "+n+" is Negative");

}

else

{

System.out.println("The given number "+n+" is neither Positive nor Negative ");

}

}

}

Output:

$ javac Postive_Negative.java

$ java Postive_Negative

Enter the number you want to check:6

The given number 6 is Positive

Similar questions