Advertisement
felix_de_suza

PointInAFigure

May 13th, 2014
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.48 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class PointInsideAFigure {
  5.    
  6.     static double rec1aX = 12.5;
  7.     static double rec1aY = 6;
  8.     static double rec1bX = 22.5;
  9.     static double rec1bY = 8.5;
  10.     static double rec2aX = 12.5;
  11.     static double rec2aY = 8.5;
  12.     static double rec2bX = 17.5;
  13.     static double rec2bY = 13.5;
  14.     static double rec3aX = 20;
  15.     static double rec3aY = 8.5;
  16.     static double rec3bX = 22.5;
  17.     static double rec3bY = 13.5;
  18.     static double pointX = 0;
  19.     static double pointY = 0;
  20.  
  21.     public static void main(String[] args) {
  22.        
  23.         Scanner input = new Scanner(System.in);
  24.        
  25.         double pointX = input.nextDouble();
  26.         double pointY = input.nextDouble();
  27.        
  28.         if (InFirstRectangle() && InSecondRectangle() && InThirdRectangle()) {
  29.             System.out.println("Inside");
  30.         }
  31.         else {
  32.             System.out.println("Outside");
  33.         }
  34.  
  35.     }
  36.  
  37.     private static boolean InFirstRectangle() {
  38.        
  39.         boolean isInside = false;
  40.         if (pointX > rec1aX && pointX < rec1bX && pointY > rec1aY &&
  41.                 pointY < rec1bY) {
  42.             isInside = true;
  43.         }
  44.         return isInside;
  45.        
  46.     }
  47.    
  48.     private static boolean InSecondRectangle() {
  49.        
  50.         boolean isInside = false;
  51.         if (pointX > rec2aX && pointX < rec2bX && pointY > rec2aY &&
  52.                 pointY < rec2bY) {
  53.             isInside = true;
  54.         }
  55.         return isInside;
  56.        
  57.     }
  58.    
  59.     private static boolean InThirdRectangle() {
  60.        
  61.         boolean isInside = false;
  62.         if (pointX > rec3aX && pointX < rec3bX && pointY > rec3aY &&
  63.                 pointY < rec3bY) {
  64.             isInside = true;
  65.         }
  66.         return isInside;
  67.        
  68.     }
  69.    
  70.  
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement