AlexKondov

Java Inside the Building

May 11th, 2014
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.36 KB | None | 0 0
  1. package Exams;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class InsideTheBuilding {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner input = new Scanner(System.in);
  9.         int h = input.nextInt();
  10.        
  11.         int x1 = input.nextInt();
  12.         int y1 = input.nextInt();
  13.         int x2 = input.nextInt();
  14.         int y2 = input.nextInt();
  15.         int x3 = input.nextInt();
  16.         int y3 = input.nextInt();
  17.         int x4 = input.nextInt();
  18.         int y4 = input.nextInt();
  19.         int x5 = input.nextInt();
  20.         int y5 = input.nextInt();
  21.        
  22.         System.out.println(isInsideBuilding(x1, y1, h));
  23.         System.out.println(isInsideBuilding(x2, y2, h));
  24.         System.out.println(isInsideBuilding(x3, y3, h));
  25.         System.out.println(isInsideBuilding(x4, y4, h));
  26.         System.out.println(isInsideBuilding(x5, y5, h));
  27.     }
  28.     public static String isInsideBuilding(int x, int y, int h) {
  29.    
  30.         String isInside;
  31.         if (x < h * 3 && x > 0) {
  32.             if (y < h) {
  33.                 isInside = "It is inside the building";
  34.                 return isInside;
  35.             }
  36.             else if  (y > h && y < h * 4) {
  37.                 if (x > h && x < h * 2) {
  38.                     isInside = "it is inside the building";
  39.                     return isInside;
  40.                 }
  41.                 else {
  42.                     isInside = "It is NOT inside the building";
  43.                     return isInside;
  44.                 }
  45.             }
  46.             else {
  47.                 isInside = "It is NOT inside the building";
  48.                 return isInside;
  49.             }
  50.         }
  51.         else {
  52.             isInside = "It is NOT inside the building";
  53.             return isInside;
  54.         }
  55.        
  56.     }
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment