Write a Java program to input a number and display 1 if it is positive and display-1 if it is negative
Answers
ydsgrsstssxri Ty rzsuikt it u
Answer: HERE IS YOUR ANSWER : -
import java.util.Scanner;
public class Greater_number
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("Input first number: ");
int n1 = in.nextInt();
System.out.print("Input second number: ");
int n2 = in.nextInt();
System.out.print("Input third number: ");
int n3 = in.nextInt();
if(n1 >= n2)
{
if(n1 >= n3)
System.out.println(n1 + " is the largest number.");
else
System.out.println(n3 + " is the largest number.");
}
else
{
if(n2 >= n3)
System.out.println(n2 + " is the largest number.");
else
System.out.println(n3 + " is the largest number.");
}
if (n1<0 && n2< 0 && n3<0)
System.out.println(" Entered numbers are negative numbers.");
else if (n1>0 && n2> 0 && n3>0)
System.out.println(" Entered numbers are positive numbers.");
else
System.out.println(" Entered numbers are mixed numbers..");
}
}
i hope his helped you, plz rate accordingly.
Explanation: