Write a program to input three numbers (positive or negative). If they are unequal then display the greatest number otherwise, display they are equal. The program also displays whether the numbers entered by the user are 'All positive', 'All negative' or 'Mixed numbers'. Sample Input: 56, -15, 12 Sample Output: The greatest number is 56 Entered numbers are mixed numbers.
Answers
Answer:
import java.util.Scanner;
public class numberprogram
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.print("Input first number: ");
int a = sc.nextInt();
System.out.print("Input second number: ");
int b = sc.nextInt();
System.out.print("Input third number: ");
int c= sc.nextInt();
if(a >= b)
{
if(a >= c)
System.out.println(a+ " is the largest number.");
else
System.out.println(c + " is the largest number.");
}
else
{
if(b >=c )
System.out.println(b + " is the largest number.");
else
System.out.println(c + " is the largest number.");
}
if (a<0 && b< 0 && c<0)
System.out.println(" Entered numbers are negative numbers.");
else if (a>0 && b> 0 && c>0)
System.out.println(" Entered numbers are positive numbers.");
else
System.out.println(" Entered numbers are mixed numbers..");
}
}
Explanation:
hope it will help you,if yes please mark me brainlist