Computer Science, asked by saritayadav96000, 7 months ago

Write a java program that check given number is positive, negative or Zero.​

Answers

Answered by BrainlyProgrammer
12

Answer:

import java.util.*;

class number

{

public static void main (String ar[])

{

Scanner sc=new Scanner (System.in);

System.out.println("Enter a number");

n=sc.nextInt();

if (n>0)

System.out.println("Positive no.");

else if (n<0)

System.out.println("Negative no.");

else

System.out.println("Zero");

}

}

Answered by anindyaadhikari13
5

Question:-

➡ Write a Java program to check whether a given number is positive, negative or zero.

Program:-

import java.util.*;

class Num

{

public static void main()

{

Scanner sc=new Scanner(System.in);

System.out.print("Enter a number: ");

int a=sc.nextInt();

if(a==0)

System.out.println("Its zero.");

else if(a>0)

System.out.println("Number is positive.");

else

System.out.println("Number is negative.");

}

}

Similar questions