First, you want to print distance
not answer
. Second, it gave you the answer on your link.... try this
public static double distance (double x0, double y1, double x1, double y0) {
return Math.hypot(x1-x0, y1-y0); // <-- From your link.
}
The formula for finding the distance between two points is precisely the same as the Pythagorean Theorem, find the length of the hypotenuse. That is c2 = a2 + b2.
Finally, you need to read in all four doublle(s)... not just one.
x0=in.nextDouble(); // Good. 1
x1=in.nextDouble(); // And another... 2
y0=in.nextDouble(); // And another... 3
y1=in.nextDouble(); // One more. 4