Computer Science, asked by akillerfreefire, 2 months ago

To check that a given number is positive, negative or

zero.​

Answers

Answered by orko2705
1

Explanation:

import java.util.Scanner;

public class Postive_Negative

{

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 ");

}

}

}

Sample Output:

$ javac Postive_Negative.java

$ java Postive_Negative

Enter the number you want to check:6

The given number 6 is Positive

Answered by sangeethakannan78
0

Explanation:

If there is a minus sign before that number it is negative number

Ex: -6

If there is a plus or no sign before that number it means it is positive number

Ex : +9 , 9

0=0

Similar questions