martinvalchev

Point In The Figure

Oct 31st, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class PointInTheFigure {
  4.     public static void main(String[] args) {
  5.  
  6.         Scanner scanner = new Scanner(System.in);
  7.  
  8.         int h = Integer.parseInt(scanner.nextLine());
  9.         int x = Integer.parseInt(scanner.nextLine());
  10.         int y = Integer.parseInt(scanner.nextLine());
  11.  
  12.         boolean firstFig = x > 0 && x < 3 * h;
  13.         boolean firstFig1 = y > 0 && y < h;
  14.         boolean secondFig = x > h && x < 2 * h;
  15.         boolean secondFig1 = y > 0 && y < 4 * h;
  16.  
  17.         if ((firstFig && firstFig1) || (secondFig && secondFig1)) {
  18.         System.out.println("inside");
  19.     } else if((x < 0 || x > 3 * h) || (y < 0 || y > 4 * h) || (y > h && (x < h || x > 2 * h))) {
  20.             System.out.println("outside");
  21.         } else {
  22.             System.out.println("border");
  23.         }
  24.  
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment