Write an algorithm, without using compound conditional expressions, that takes in three integers and determines if they are all distinct. On average, how many comparisons does your algorithm do? Remember to examine all input classes.
please please thumbs up!!
hope it will help uh out!!
Code::
(IN JAVA PROGRAMMING LANGUAGE)
---------------------------------------------------------
NOTE :: HERE BELOW IS THE ALGORITHM WITHOUT USING COMPOUND COMDITIONAL EXPRESSION AS YOU WANT FOR ABOVE PROBLEM::-
import java.util.Scanner;
class Distinct {
public static void main (String args[])
{
int x, y, z;
Scanner scanner = new Scanner(System.in);
System.out.println("Enter first number");
x = scanner.nextInt();
System.out.println("Enter second number");
y = scanner.nextInt();
System.out.println("Enter third number");
z = scanner.nextInt();
int check = 0;
if (x != y)
if (y !=
z)
if (x != z)
check = 1;
if (check == 1)
System.out.println("Numbers
are distinct");
else
System.out.println("Numbers
are not distinct");
}
}
-------------------------------------------------
output::
IN GENERAL WE HAVE TO MAKE THREE COMPARISIONS
Get Answers For Free
Most questions answered within 1 hours.