RGAlex

O2. Center Point / Methods - More Exercise

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