-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClass_Point.java
More file actions
54 lines (44 loc) · 1.39 KB
/
Copy pathClass_Point.java
File metadata and controls
54 lines (44 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import java.util.Scanner;
public class Class_Point {
public static class Point {
private Double x;
private Double y;
public Point() {
this.x = 0.0;
this.y = 0.0;
}
public Point(Double x, Double y) {
this.x = x;
this.y = y;
}
public Point(Point p) {
this.x = p.x;
this.y = p.y;
}
public Double getX() {
return this.x;
}
public Double getY() {
return this.y;
}
public Double distance(Point secondP) {
return Math.sqrt((this.x - secondP.x) * (this.x - secondP.x) + (this.y - secondP.y) * (this.y - secondP.y));
}
public static Double distance(Point a, Point b) {
return Math.sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
}
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
while(t-- > 0) {
double a = in.nextDouble();
double b = in.nextDouble();
double c = in.nextDouble();
double d = in.nextDouble();
Point x = new Point(a, b);
Point y = new Point(c, d);
System.out.printf("%.4f\n", Point.distance(x, y));
}
}
}