Question:
Snapshot of the question has been attached to this response.
Answer:
import java.util.Scanner;
import java.lang.Math;
public class CoordinateGeometry{
public static void main(String []args){
double x1 = 1.0;
double y1 = 2.0;
double x2 = 1.0;
double y2 = 5.0;
double pointsDistance = 0.0;
//Declare a variable to hold the result of (x2 - x1)²
double x;
//Solve (x2 - x1)^2 and store result in the variable x
x = Math.pow(x2 - x1, 2);
//Declare a variable to hold the result of (y2 - y1)²
double y;
//Solve (y2 - y1)^2 and store result in the variable y
y = Math.pow(y2 - y1, 2);
//Now pointsDistance = SquareRootOf(x + y)
pointsDistance = Math.sqrt(x + y);
System.out.println("Points distance: ");
System.out.println(pointsDistance);
return;
}
}
Sample Output:
Points distance:
3.0
Step-by-step explanation:
The above code has been written in Java and it contains comments explaining important lines of the code. Please go through the comments.
The snapshots of the program and a sample output have been attached to this response.