Advertisement
tchenkov

L04u06_PointOnRectangleBorder

Jan 23rd, 2017
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.12 KB | None | 0 0
  1. package Uprajneniq;
  2.  
  3. import java.util.Scanner;
  4.  
  5. /**
  6.  * Created by todor on 23.01.2017 г..
  7.  */
  8. public class u06_PointOnRectangleBorder {
  9.     public static void main(String[] args) {
  10.  
  11.         Scanner scan = new Scanner(System.in);
  12.  
  13.         double x1 = Double.parseDouble(scan.nextLine());
  14.         double y1 = Double.parseDouble(scan.nextLine());
  15.         double x2 = Double.parseDouble(scan.nextLine());
  16.         double y2 = Double.parseDouble(scan.nextLine());
  17.         double x = Double.parseDouble(scan.nextLine());
  18.         double y = Double.parseDouble(scan.nextLine());
  19.  
  20.         boolean isOnLeftBorder = x == x1 && (y1 <= y && y <= y2);
  21.         boolean isOnRightBorder = x == x2 && (y1 <= y && y <= y2);
  22.         boolean isOnTopBorder = y == y1 && (x1 <= x && x <= x2);
  23.         boolean isOnBottomBorder = y == y2 && (x1 <= x && x <= x2);
  24.  
  25.         boolean isOnAnyBorder = isOnLeftBorder || isOnRightBorder || isOnTopBorder || isOnBottomBorder;
  26.  
  27.         if (isOnAnyBorder) {
  28.             System.out.println("Border");
  29.         }
  30.         else {
  31.             System.out.println("Inside / Outside");
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement