Computer Science, asked by Pranavbhat16, 1 year ago

Write a Java program to input a number and to check whether it is a positive or negative

Answers

Answered by vyomgupta
16
the input codes are as follow
import java.util.Scanner;
public class Postive_Negative
{
public static void main(String[] args)
{
int n;
Scanner s = new Scanner(System.in);
System.out.print("Enter the number you want to check:");
n = s.nextInt();
if(n > 0)
{
System.out.println("The given number "+n+" is Positive");
}
else if(n < 0)
{
System.out.println("The given number "+n+" is Negative");
}
else
{
System.out.println("The given number "+n+" is neither Positive nor Negative ");
}
}
}

Pranavbhat16: oh!!!!
Pranavbhat16: 9 .....
Pranavbhat16: Mitra Academy Bangalore
Pranavbhat16: u?
Pranavbhat16: doomdooma is a place????
Pranavbhat16: oh...
Answered by BrainlyPromoter
4

import java.util.*;

class Pract

{

   public static void Practice()

   {

       Scanner Promoter = new Scanner(System.in);

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

       double a = Promoter.nextDouble();

       if(a>0)

           System.out.println("The number is positive.");

       else if(a<0)

           System.out.println("The number is negative.");

       else

           System.out.println("The number is a zero.");

   }

}

Output:

Enter the number: 56

The number is positive.

Similar questions