Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class LongerLine {
- private static void centerPoint(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) {
- double longFirstLine = Math.sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
- double longSecondLine = Math.sqrt((x3 - x4)*(x3 - x4) + (y3 - y4)*(y3 - y4));
- if (longFirstLine >= longSecondLine) {
- if ((Math.abs(x1) + Math.abs(y1)) < (Math.abs(x2) + Math.abs(y2))) {
- System.out.printf("(%.0f, %.0f)(%.0f, %.0f)", x1, y1, x2, y2);
- } else {
- System.out.printf("(%.0f, %.0f)(%.0f, %.0f)", x2, y2,x1, y1);
- }
- } else {
- if ((Math.abs(x3) + Math.abs(y3)) < (Math.abs(x4) + Math.abs(y4))) {
- System.out.printf("(%.0f, %.0f)(%.0f, %.0f)", x3, y3, x4, y4);
- }else {
- System.out.printf("(%.0f, %.0f)(%.0f, %.0f)", x4, y4, x3, y3);
- }
- }
- }
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double x1 = Double.parseDouble(scanner.nextLine());
- double y1 = Double.parseDouble(scanner.nextLine());
- double x2 = Double.parseDouble(scanner.nextLine());
- double y2 = Double.parseDouble(scanner.nextLine());
- double x3 = Double.parseDouble(scanner.nextLine());
- double y3 = Double.parseDouble(scanner.nextLine());
- double x4 = Double.parseDouble(scanner.nextLine());
- double y4 = Double.parseDouble(scanner.nextLine());
- centerPoint(x1, y1, x2, y2,x3, y3, x4, y4);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement