write a program in java to input a number and check if its positive or not
Answers
Answer:
in java to input a number and check
Explanation:
Java Program to Check if a Given Integer is Positive or Negative
1. public class Postive_Negative.
int n;
2.Scanner s = new Scanner(System.
System. out. print("Enter the number you want to check:");
n = s. nextInt();
if(n > 0)
3.System. out. println("The given number "+n+" is Positive");
else if(n < 0)
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 ");
}
}
}