bluej Programs
3.Write a program to enter a values,check whether it is positive or negative or equal to zero.
import java.util.*;
class positive_negative
{
void main()
{
Scanner sc=new Scanner(System.in);
int n;
System.out.println("Enter a number:");
n=sc.nextInt();
if(n>0)
System.out.println("Positive");
else if(n<0)
System.out.println("Negative");
else
System.out.println("Equalto Zero");
}
}
Output:
Enter a number: -98 Negative
ADVERTISEMENT
