daily pastebin goal
66%
SHARE
TWEET

Untitled

a guest Feb 17th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.text.DecimalFormat;
  2. import java.util.Arrays;
  3. import java.util.Scanner;
  4.  
  5. public class kur {
  6.  
  7.     static String closestToCenterCheck (int firstX, int firstY, int secondX, int secondY) {
  8.  
  9.         String closest = "";
  10.  
  11.         int absFirstX = Math.abs(firstX);
  12.         int absFirstY = Math.abs(firstY);
  13.         int absSecondX = Math.abs(secondX);
  14.         int absSecondY = Math.abs(secondY);
  15.  
  16.         if (absFirstX + absFirstY < absSecondX + absSecondY) {
  17.             closest += firstX + ", " + firstY;
  18.         }else if(absFirstX + absFirstY > absSecondX + absSecondY) {
  19.             closest += secondX + ", " + secondY;
  20.         }else {
  21.             closest += firstX + ", " + firstY;
  22.         }
  23.  
  24.         return closest;
  25.     }
  26.  
  27.  
  28.  
  29.     public static void main(String[] args) {
  30.  
  31.         Scanner sc = new Scanner(System.in);
  32.  
  33.         int firstX = Integer.parseInt(sc.nextLine());
  34.         int firstY = Integer.parseInt(sc.nextLine());
  35.         int secondX = Integer.parseInt(sc.nextLine());
  36.         int secondY = Integer.parseInt(sc.nextLine());
  37.  
  38.         System.out.println("(" + closestToCenterCheck(firstX, firstY, secondX, secondY) + ")");
  39.  
  40.  
  41.  
  42.     }
  43. }
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