Write a java program that check given number is positive, negative or Zero.
Answers
Answered by
12
Answer:
import java.util.*;
class number
{
public static void main (String ar[])
{
Scanner sc=new Scanner (System.in);
System.out.println("Enter a number");
n=sc.nextInt();
if (n>0)
System.out.println("Positive no.");
else if (n<0)
System.out.println("Negative no.");
else
System.out.println("Zero");
}
}
Answered by
5
Question:-
➡ Write a Java program to check whether a given number is positive, negative or zero.
Program:-
import java.util.*;
class Num
{
public static void main()
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter a number: ");
int a=sc.nextInt();
if(a==0)
System.out.println("Its zero.");
else if(a>0)
System.out.println("Number is positive.");
else
System.out.println("Number is negative.");
}
}
Similar questions
Math,
3 months ago
English,
3 months ago
Hindi,
3 months ago
India Languages,
7 months ago
Math,
1 year ago