Q:

Java Program to Find Number Is Positive or Negative

0

Problem :- Java Program To Find Number Is Positive Or Negative or Java Program to Check if a Given Integer is Positive or Negative or Java Program to check if Number is Positive or Negative or Java program to find Positive or Negative Number or Java Program to Count Positive, Zero, and Negative Numbers or How to check if a Number is Positive or Negative in Java or Java Program To Check Whether Number Is Positive Or Negative. Write A Java Program To Check Number Is Positive Or Negative.


Logic:- Checking Number is positive or negative number should be entered through user then program print the output. As we know that if the number is greater than 0 ( Zero ) Than number is positive and if the number is Less than 0 ( Zero ) that number is Negative and else number is equal to zero than an entered number is Zero.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import java.util.Scanner;
import java.io.*;

public class Posi_Negative 
{
    public static void main(String[] args) 
    {
        int number;
        Scanner scan = new Scanner(System.in);
        System.out.print("Enter The Number You Want to Check:");
        number = scan.nextInt();
        if(number > 0)
        {
            System.out.println("The Number Is "+number+" is Positive");
        }
        else if(number < 0)
        {
            System.out.println("The Number Is "+number+" is Negative");
        }
        else
        {
            System.out.println("The Number Is "+number+" is Zero ");
        }
    }
}

 

Output:

--------------

Enter The Number You Want to Check:-10

The Number Is -10 is Negative

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now