import java.awt.geom.Point2D;
class ComputeDistance {
public static void main (String args[]) {
double sum;
Point2D.Double p1 = new Point2D.Double(371880.4954, 2782119.892);
Point2D.Double p2 = new Point2D.Double(371749.3277, 2781015.385);
Point2D.Double p3 = new Point2D.Double(373287.0808, 2779773.921);
Point2D.Double p4 = new Point2D.Double(373722.4445, 2780534.667);
Point2D.Double p5 = new Point2D.Double(374067.5787, 2780825.884);
System.out.println("P1到P2的距離: " + p1.distance(p2));
System.out.println("P2到P3的距離: " + p2.distance(p3));
System.out.println("P3到P4的距離: " + p3.distance(p4));
System.out.println("P4到P5的距離: " + p4.distance(p5));
sum = p1.distance(p2) + p2.distance(p3) + p3.distance(p4) + p4.distance(p5);
System.out.println("總距離為: " + sum);
}
}
沒有留言:
張貼留言