Advertisement
YavorGrancharov

PointInRectangle

Jan 21st, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.85 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class PointOnRectangleBorder {
  4.     public static void main(String[] args) {
  5.         Scanner console = new Scanner(System.in);
  6.         double x1 = Double.parseDouble(console.nextLine());
  7.         double y1 = Double.parseDouble(console.nextLine());
  8.         double x2 = Double.parseDouble(console.nextLine());
  9.         double y2 = Double.parseDouble(console.nextLine());
  10.         double x = Double.parseDouble(console.nextLine());
  11.         double y = Double.parseDouble(console.nextLine());
  12.  
  13.         boolean conditionForX = (x == x1 || x == x2) && (y >= y1 && y <= y2);
  14.         boolean conditionForY = (y == y1 || y == y2) && (x >= x1 && x <= x2);
  15.  
  16.         if (conditionForX || conditionForY) {
  17.             System.out.println("Border");
  18.         } else {
  19.             System.out.println("Inside / Outside");
  20.         }
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement