Write a Java Program to Check if a Number is Positive, Negative or Zero.

Write a Java Program to Check if a Number is Positive, Negative or Zero.

Write a Java Program to Check if a Number is Positive, Negative or Zero.

Program
import java.util.Scanner;
public class Main 
{
    public static void main(String[] args) 
    {
        int num;
        Scanner s=new Scanner(System.in);
        System.out.println("Enter a number: ");
        num=s.nextInt();
        		
        if(num>0)
        {
            System.out.println("Positive number");
        }
        else if(num==0)
        {
            System.out.println("Zero");
        }
        else
        {
            System.out.println("Negative number");	
        }	
    }
}



Output:

Enter a number: 28
Positive number



More Questions


28 . Write a Java program to convert Celsius to Fahrenheit.
29 . Write a Java Program to Check if a Number is Positive, Negative or Zero.
30 . Write a Java Program to Find the sum of the digits of a number
31 . Write a Java Program to Calculate electricity bill
32 . Write a Java Program to find Armstrong number
33 . Write a java Program to print Armstrong number between 1 to 1000
34 . Write a java Program to Print given number in words
35 . Write a java Program to check the given number is Palindrome or not
36 . Write a java Program to print palindrome number upto N numbers
37 . Write a java Program to print N prime numbers and find sum and average
38 . Write a Java Program to find largest number in an array



For latest job updates join Telegram Channel: https://t.me/sateeshm

Apply For The Job

Apply For Job

Java Material

Python Material

PLSQL Material

.Net Material

Java Practice Programs

400 Java Programs