Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class _1_InsideTheBuilding {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Scanner scan = new Scanner(System.in);
- int size = scan.nextInt();
- for (int i = 0; i < 5; i++) {
- int pointX = scan.nextInt();
- int pointY = scan.nextInt();
- boolean pointInsideInBase = checkThePointIsInsideInBase(size,
- pointX, pointY);
- boolean pointInsideInTower = checkThePointIsInsideInTower(size,
- pointX, pointY);
- String result = (pointInsideInBase || pointInsideInTower) ? "inside"
- : "outside";
- System.out.println(result);
- }
- }
- private static boolean checkThePointIsInsideInBase(int size, int x, int y) {
- // TODO Auto-generated method stub
- int maxX = 3 * size;
- boolean isInside = x >= 0 && x <= maxX && y >= 0 && y <= size;
- return isInside;
- }
- private static boolean checkThePointIsInsideInTower(int size, int x, int y) {
- // TODO Auto-generated method stub
- int maxX = 2 * size;
- int maxY = 4 * size;
- boolean isInside = x >= size && x <= maxX && y >= size && y <= maxY;
- return isInside;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement