Java Program to Print the number is either positive negative or zero.

 Java Program to Print the number is either positive negative or zero.

In this java program, we will read integer number and check whether it is positive, negative or zero.

Using If-else statement with Method 


import java.util.Scanner;

class Number
{
String pnz(int a)
{
if(a<0)
return "Negative";
else if(a>0)
return "Positive";
return "Zero";
}
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter a number.");
int x=sc.nextInt();
Number n=new Number();
System.out.println(n.pnz(x));
}
}

Comments

Popular posts from this blog

Java Program for shop Bill to Calculate total amount of product with discount

RCM|Consequences of imbalanced Nutrition|WHO share daily need

Learn Data structures and algorithms concepts free online with certificate