Computer Science, asked by gigipaul1971, 6 months ago

8. Write a program to input three unequal numbers. Display the greatest and the
smallest number.
Sample Input: 28, 98, 56
Sample Output: Greatest Number: 98
Smallest Number: 28​

Answers

Answered by ArpitMishra506
10

// Using Java Function

public class Check

{

public static void main(int num1, int num2, int num3)

{

int Greatest=0;

int Smallest=0;

if(num1==num2 || num2==num3 || num3==num1) System.out.println("Numbers are not unequal");

System.out.println(" Greatest "+Math.max(num1, num2), num3) ;

System.out.println(" Smallest "+Math.min(num1, num2), num3) ;

}

}

//Without Using Java Library

public class Check

{

public static void main(int num1, int num2, int num3)

{

int Greatest=0;

int Smallest=0;

if(num1==num2 || num2==num3 || num3==num1)

System.out.println("Numbers are not unequal");

else

{

if(num1>num2 && num1>num3)

Greatest=num1;

else if(num2>num1 && num2>num3)

Greatest=num2;

else

Greatest=num3;

if(num1<num2 && num1<num3)

Smallest=num1;

else if(num2<num1 && num2<num3)

Smallest=num2;

else

Smallest=num3;

}

System.out.println(" Greatest "+Greatest) ;

System.out.println(" Smallest "+Smallest) ;

}

}

.

.

.

.

.

HOPE THIS HELPS YOU

.

.

.

.

.

PLEASE MARK AS BRAINLIEST AND FOLLOW ME TOO

Similar questions