Advertisement
Guest User

Untitled

a guest
Feb 17th, 2019
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1. package Methods;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class CenterPoint {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         int X1 = Integer.parseInt(scanner.nextLine());
  10.         int Y1 = Integer.parseInt(scanner.nextLine());
  11.         int X2 = Integer.parseInt(scanner.nextLine());
  12.         int Y2 = Integer.parseInt(scanner.nextLine());
  13.  
  14.         closerToCenter(X1, Y1, X2, Y2);
  15.  
  16.  
  17.     }
  18.  
  19.     static void closerToCenter(int x1, int y1, int x2, int y2) {
  20.  
  21.         if (Math.abs(x1) <= Math.abs(x2) && Math.abs(y1) <= Math.abs(y2)) {
  22.             System.out.printf("(%d, %d)", x1, y1);
  23.         } else {
  24.             System.out.printf("(%d, %d)", x2, y2);
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement