-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCenterPoint.java
More file actions
31 lines (21 loc) · 864 Bytes
/
Copy pathCenterPoint.java
File metadata and controls
31 lines (21 loc) · 864 Bytes
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
package Methods;
import java.util.Scanner;
public class CenterPoint {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double x1 =Double.parseDouble(scanner.nextLine());
double y1 =Double.parseDouble(scanner.nextLine());
double x2 =Double.parseDouble(scanner.nextLine());
double y2 =Double.parseDouble(scanner.nextLine());
printClosestPoint(x1,y1,x2,y2);
}
public static void printClosestPoint(double x1,double y1,double x2,double y2){
double firstPoint = Math.sqrt(Math.pow(x1,2) + Math.pow(y1,2));
double secondPoint = Math.sqrt(Math.pow(x2,2) + Math.pow(y2,2));
if(firstPoint <= secondPoint){
System.out.printf("(%.0f, %.0f)",x1,y1);
}else {
System.out.printf("(%.0f, %.0f)",x2,y2);
}
}
}