27 August 2018

Java Program to check a given number is positive/negative/zero

//Program to check a given number is positive/negative/zero
import java.util.*;
class check
     {
public static void main(String args[])
      {

    int n;
    System.out.println(" Enter a number:");
    Scanner obj=new Scanner(System.in);
    n=obj.nextInt();
    if(n<0)
        System.out.println(" Entered number is negative ");
    else if(n==0)
        System.out.println(" Entered number is Zero ");
    else
        System.out.println(" Entered number is positive ");
      }
     }

No comments:

Post a Comment

To convert from Upper case to lowercase(A to a)

//converting from Upper to lower(A to a) import java.util.*; class case { public static void main(String args[]) { System.out.pr...