Advertisement
drago68

Untitled

Oct 14th, 2019
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class LongerLine {
  6.  
  7.  
  8. private static void centerPoint(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) {
  9.  
  10. double longFirstLine = Math.sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
  11. double longSecondLine = Math.sqrt((x3 - x4)*(x3 - x4) + (y3 - y4)*(y3 - y4));
  12. if (longFirstLine >= longSecondLine) {
  13. if ((Math.abs(x1) + Math.abs(y1)) < (Math.abs(x2) + Math.abs(y2))) {
  14. System.out.printf("(%.0f, %.0f)(%.0f, %.0f)", x1, y1, x2, y2);
  15. } else {
  16. System.out.printf("(%.0f, %.0f)(%.0f, %.0f)", x2, y2,x1, y1);
  17. }
  18. } else {
  19. if ((Math.abs(x3) + Math.abs(y3)) < (Math.abs(x4) + Math.abs(y4))) {
  20. System.out.printf("(%.0f, %.0f)(%.0f, %.0f)", x3, y3, x4, y4);
  21. }else {
  22. System.out.printf("(%.0f, %.0f)(%.0f, %.0f)", x4, y4, x3, y3);
  23. }
  24. }
  25. }
  26. public static void main(String[] args) {
  27. Scanner scanner = new Scanner(System.in);
  28.  
  29. double x1 = Double.parseDouble(scanner.nextLine());
  30. double y1 = Double.parseDouble(scanner.nextLine());
  31. double x2 = Double.parseDouble(scanner.nextLine());
  32. double y2 = Double.parseDouble(scanner.nextLine());
  33. double x3 = Double.parseDouble(scanner.nextLine());
  34. double y3 = Double.parseDouble(scanner.nextLine());
  35. double x4 = Double.parseDouble(scanner.nextLine());
  36. double y4 = Double.parseDouble(scanner.nextLine());
  37. centerPoint(x1, y1, x2, y2,x3, y3, x4, y4);
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement