Write the following method and provide a program to test them 1) boolean allDifferent(double x, double y, double z), returning true if the arguments are all different. I had been struggling with writing method programs. I would appreciate help in this!
Write the following method and provide a program to test them
1) boolean allDifferent(double x, double y, double z), returning true if the arguments are all different.
I had been struggling with writing method programs. I would appreciate help in this!
This is what I did so far:
import java.util.Scanner;
public class Equality
{
public static void main(String[] args)
{
result = allDifferent(x,y,z);
System.out.print(result);
}
public static boolean allDifferent(double x, double y, double z)
{
Scanner in = new Scanner(System.in);
System.out.print("Enter x: ");
x = in.nextDouble();
System.out.print("Enter y: ");
y = in.nextDouble();
System.out.print("Enter z: ");
z = in.nextDouble();
boolean result = false;
if(x==y && y==z)
{
result = true;
}
return result;
}
}

Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images









