daily pastebin goal
85%
SHARE
TWEET

Center Point

damesova Feb 17th, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class _02_CenterPoint {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int x1 = Integer.parseInt(scanner.nextLine());
  8.         int y1 = Integer.parseInt(scanner.nextLine());
  9.         int x2 = Integer.parseInt(scanner.nextLine());
  10.         int y2 = Integer.parseInt(scanner.nextLine());
  11.  
  12.         if (findDiagonal(x1, y1) <= findDiagonal(x2, y2)){
  13.             System.out.printf("(%d, %d)", x1, y1);
  14.         } else {
  15.             System.out.printf("(%d, %d)", x2, y2);
  16.         }
  17.     }
  18.  
  19.     private static double findDiagonal(int x, int y){
  20.         double a = x * 1.0;
  21.         double b = y * 1.0;
  22.  
  23.         return Math.sqrt(Math.abs((Math.pow(a, 2)) + (Math.pow(b, 2))));
  24.     }
  25. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top