Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class PointInsideAFigure {
- static double rec1aX = 12.5;
- static double rec1aY = 6;
- static double rec1bX = 22.5;
- static double rec1bY = 8.5;
- static double rec2aX = 12.5;
- static double rec2aY = 8.5;
- static double rec2bX = 17.5;
- static double rec2bY = 13.5;
- static double rec3aX = 20;
- static double rec3aY = 8.5;
- static double rec3bX = 22.5;
- static double rec3bY = 13.5;
- static double pointX = 0;
- static double pointY = 0;
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- double pointX = input.nextDouble();
- double pointY = input.nextDouble();
- if (InFirstRectangle() && InSecondRectangle() && InThirdRectangle()) {
- System.out.println("Inside");
- }
- else {
- System.out.println("Outside");
- }
- }
- private static boolean InFirstRectangle() {
- boolean isInside = false;
- if (pointX > rec1aX && pointX < rec1bX && pointY > rec1aY &&
- pointY < rec1bY) {
- isInside = true;
- }
- return isInside;
- }
- private static boolean InSecondRectangle() {
- boolean isInside = false;
- if (pointX > rec2aX && pointX < rec2bX && pointY > rec2aY &&
- pointY < rec2bY) {
- isInside = true;
- }
- return isInside;
- }
- private static boolean InThirdRectangle() {
- boolean isInside = false;
- if (pointX > rec3aX && pointX < rec3bX && pointY > rec3aY &&
- pointY < rec3bY) {
- isInside = true;
- }
- return isInside;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement