Advertisement
Spocoman

08. Point on Rectangle Border

Aug 26th, 2024
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class PointOfRectangleBorder {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         double x1 = Double.parseDouble(scanner.nextLine());
  7.         double y1 = Double.parseDouble(scanner.nextLine());
  8.         double x2 = Double.parseDouble(scanner.nextLine());
  9.         double y2 = Double.parseDouble(scanner.nextLine());
  10.         double x = Double.parseDouble(scanner.nextLine());
  11.         double y = Double.parseDouble(scanner.nextLine());
  12.  
  13.         boolean firstCondition = (x == x1 || x == x2) && (y >= y1 && y <= y2);
  14.         boolean secondCondition = (y == y1 || y == y2) && (x >= x1 && x <= x2);
  15.  
  16.         System.out.println(firstCondition || secondCondition ? "Border" : "Inside / Outside");
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement