Write a program to input three numbers and check whether they are equal
or not. If they are unequal numbers then display the greatest among them
otherwise, display the message 'All the numbers are equal'.
Sample Input: 34, 87, 61
Sample Output: Greatest number: 87
Sample Input: 81, 81, 81
Sample Output: All the numbers are equal.
Pls solve using scanner class(conditional statements like if, else - if, etc.
Answers
Answer:
// Java program to display the numbers
import java.util.*;
public class Numbers
{
public static void main()
{
Scanner in= new Scanner(System.in);
System.out.println("Enter the first number");
int a = in.nextInt();
System.out.println("Enter the second number");
int b= in.nextInt();
System.out.println("Enter the third number");
int c= in.nextInt();
if ( a==b && b== c && c==a)
{
System.out.println("All the numbers are equal");
}
else
if (a>b &&a>c)
System.out.println("Greatest Number:" +a);
if (b>a &&b>c)
System.out.println("Greatest Number:" +b);
if (c>a &&c>b)
System.out.println("Greatest Number:" +c);
}
}
Answer:// Java program to display the numbers
import java.util.*;
public class Numbers
{
public static void main()
{
Scanner in= new Scanner(System.in);
System.out.println("Enter the first number");
int a = in.nextInt();
System.out.println("Enter the second number");
int b= in.nextInt();
System.out.println("Enter the third number");
int c= in.nextInt();
if ( a==b && b== c && c==a)
{
System.out.println("All the numbers are equal");
}
else
if (a>b &&a>c)
System.out.println("Greatest Number:" +a);
if (b>a &&b>c)
System.out.println("Greatest Number:" +b);
if (c>a &&c>b)
System.out.println("Greatest Number:" +c);
}
}
Read more on Brainly.in - https://brainly.in/question/11496700#readmore