brel-logo-white brel-logo-white
  • Travel
  • Case Study
  • How to
  • Technology
  • More
    • Sports
    • Health
    • Articles
    • Review
Notification
  • HomeHome
  • Finance
  • Health
  • Lifestyle
  • Sports
  • Contact Us
BreldigitalBreldigital
  • HomeHome
  • Finance
  • Health
  • Lifestyle
  • Sports
  • Contact Us
Search
  • Quick Access
    • Home
    • History
    • My Saves
    • My Interests
    • My Feed
  • Categories
    • Travel
    • Sports
    • Health

Top Stories

Explore the latest updated news!

How many solutions exist for the given equation? 3x + 13 = 3(x + 6) + 1 zero one two infinitely many

What is a best practice when approaching an automation effort

How does using mynav allow accenture to help its clients become more sustainable?

Stay Connected

Find us on socials
248.1k Followers Like
61.1k Followers Follow
165k Subscribers Subscribe
Breldigital > Blog > ds > How to check if a number is positive or negative in java
ds

How to check if a number is positive or negative in java

By John Published November 10, 2022
Share

This is a Java Program to Check if a Given Integer is Positive or Negative.
Enter any integer number as an input. Now we check whether the given number is greater than zero or not. If the given number is greater than zero than it is positve. If it is less than zero than it is negative and if it is zero than it is neither poistive nor negative.

Here is the source code of the Java Program to Check if a Given Integer is Positive or Negative. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.

import java.util.Scanner;
public class Postive_Negative
{
public static void main(String[] args)
{
int n;
Scanner s = new Scanner(System.in);
System.out.print(“Enter the number you want to check:”);
n = s.nextInt();
if(n > 0)
{
System.out.println(“The given number “+n+” is Positive”);
}
else if(n < 0) { System.out.println("The given number "+n+" is Negative"); } else { System.out.println("The given number "+n+" is neither Positive nor Negative "); } } } Output: $ javac Postive_Negative.java $ java Postive_Negative Enter the number you want to check:6 The given number 6 is Positive

TAGGED: How to check if a number is positive or negative in java
John November 10, 2022 November 10, 2022

Search

brel-logo-white brel-logo-white
Explore a wide range of brands and categories with our comprehensive coverage, and stay up-to-date with the latest news and trends by subscribing to our updates.
Categories:
  • Entertainment
  • Travel
  • Sport
  • Contact Us

Quick Links

  • My Feed
  • My Interests
  • History
  • My Saves

About US

  • Adverts
  • Our Jobs
  • Term of Use

© 2023 Brel Digital All Rights Reserved. All logos and images used on this website are registered trademarks of their respective companies

Welcome Back!

Sign in to your account

Lost your password?