Write a Java program to input a number and to check whether it is a positive or negative
Answers
Answered by
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 ");
}
}
}
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!!!!
Answered by
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
Social Sciences,
1 year ago