The following code demonstrates how to Check Whether a Number is Positive in Java.

Basically, this program allows a user to enter a number. It checks whether the entered number is positive, negative, or zero.

import java.util.Scanner;
public class Exercise1A
{
	public static void main(String[] args) {
		int my_num;
		System.out.println("Enter a Number: ");
		Scanner scn=new Scanner(System.in);
		my_num=scn.nextInt();
		if(my_num>0)
			System.out.println(my_num+" is positive!");
		else
			if(my_num<0)
				System.out.println(my_num+" is negative!");
			else
				System.out.println(my_num+" is zero!");
	}
}

Output

A Program to Check Whether a Number is Positive in Java
A Program to Check Whether a Number is Positive in Java

Further Reading

Java Practice Exercise

programmingempire

Princites