Advertisement
M_Andreev

PointsInsideAFigure

Sep 7th, 2014
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.07 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class _03_PointsInsideAFigure {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner sc = new Scanner(System.in);
  7.         System.out.print("Ax: ");
  8.         double ax = sc.nextDouble();
  9.         System.out.print("Ay: ");
  10.         double ay = sc.nextDouble();
  11.        
  12.         if ((isInSquare(ax, ay) || isInRectangle(ax, ay) || isInRec(ax, ay)) == true) {
  13.             System.out.print("Inside");
  14.         }
  15.         else {
  16.             System.out.println("Outside");
  17.         }
  18.     }
  19.  
  20.     public static boolean isInSquare(double ax, double ay){
  21.         boolean result = false;
  22.        
  23.         if (ax >= 12.5 && ax <= 17.5) {
  24.             if (ay >= 8.5 && ay <= 13.5) {
  25.                 result = true;
  26.             }
  27.         }
  28.         return result;
  29.     }
  30.    
  31.     public static boolean isInRectangle(double ax, double ay){
  32.         boolean result = false;
  33.        
  34.         if (ax >= 12.5 && ax <= 22.5) {
  35.             if (ay >= 6 && ay <= 8.5) {
  36.                 result = true;
  37.             }
  38.         }
  39.         return result;
  40.     }
  41.    
  42.     public static boolean isInRec(double ax, double ay){
  43.         boolean result = false;
  44.        
  45.         if (ax >= 20 && ax <= 22.5) {
  46.             if (ay >= 8.5 && ay <= 13.5) {
  47.                 result = true;
  48.             }
  49.         }
  50.         return result;
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement