I am new to programming and for my class I have to write a method and program for the following:

boolean allTheSame(double x, double y, double z) returning the average of the arguments.

public static void main(String[] args) {
    // **METHOD**//

    Scanner in = new Scanner(;

    System.out.println("Enter variable for x");
    double x = in.nextDouble();

    System.out.println("Enter variable for y");
    double y = in.nextDouble();

    System.out.println("Enter variable for z");
    double z = in.nextDouble();

    boolean allTheSame = boolean allTheSame(x, y, z);


    // **TEST PROGRAM** //
 public static boolean allTheSame(double x, double y, double z)

     if (x == y && x == z)
            return true;

            return false;



Given the fact that I am new, how can I do this?

Was it helpful?


boolean allTheSame = allTheSame(x, y, z);

You don't need to put boolean before you call the method.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow