Sunday, 5 November 2017

java program that check number is positive or negitive or zero



Problem 07:
Write a program that check number is positive negative or zero.
Discripition:
If number is greater then zero the number is positive if number is lessthen zero number is negative if number is equal to zero number is zero.
Solution:
import java.util.*;
public class Message {
 public static void main(String[] args) {
  Scanner input= new Scanner(System.in);
   System.out.println("Enter the  number");
    int num1=input.nextInt();
    if(num1>0)
         System.out.println("The number "+num1+" is positive");
   if(num1<0)
         System.out.println("The number "+num1+" is negitive");
   if(num1==0)
         System.out.println("The number "+num1+" is Zero");
 }}
Output:

No comments:

Post a Comment