Texts: CHALLENGE ACTIVITY
3.10.3 Using math functions to calculate the distance between two points
Determine the distance between point (x1, y1) and point (x2, y2) and assign the result to pointsDistance. The calculations are as follows:
Distance = √((x2 - x1)^2 + (y2 - y1)^2)
For points (1.0, 2.0) and (1.0, 5.0), pointsDistance is 3.0.
See "How to Use zvBooks" for information on how our automated program grader works.
import java.util.Scanner;
public class CoordinateGeometry {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
double x1, y1;
double x2, y2;
double pointsDistance;
double xDist;
double yDist;
pointsDistance = 0.0;
xDist = 0.0;
yDist = 0.0;
// Run the program
}
}