计算两点距离
import java.util.Scanner;
public class Point {
double x, y;
public void get() {
Scanner s = new Scanner(System.in);
System.out.println("please input x:>");
x = s.nextDouble();
System.out.println("please input y:>");
y = s.nextDouble();
}
public double dis(Point p) {
return Math.sqrt((x - p.x) * (x - p.x) + (y - p.y) * (y - p.y));
}
public static void main(String[] args) {
Point p1=new Point();
p1.get();
Point p2=new Point();
p2.get();
double distance=p2.dis(p1);
System.out.println("distance is "+distance);
}
}