Advertisement
veronikaaa86

PointOnRectangleBorder

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