OneCompiler

Write a program to accept a number and check if it is positive negative or zero

208

import java.util.*;
public class posnegzero {
public static void main(String[] args) {
Scanner sc = new Scanner (System.in);
System.out.println("Enter a number : ");
int n1=sc.nextInt();
if(n1>0)
System.out.println("The number "+ n1+ " is positive");
else
if(n1<0)
System.out.println("The number " + n1+ " is negative");
else
if(n1==0)
System.out.println("The number "+ n1+ " is equal to zero");
}
}