Venciity

[SoftUni Java] Syntax - 03.PointsInsideAFigure

May 12th, 2014
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class PointsInsideAFigure {
  5.  
  6.     public static void main(String[] args) {
  7.         // check how to set invariant culture
  8.         Scanner input = new Scanner(System.in);
  9.         double x = input.nextDouble();
  10.         double y = input.nextDouble();
  11.        
  12.         boolean insideFirstFigure = (x >= 12.5) && (x <= 22.5) && (y >= 6) && (y <= 8.5);
  13.         boolean insideSecondFigure = (x >= 12.5) && (x <= 17.5) && (y >= 8.5) && (y <= 13.5);
  14.         boolean insideThirdFigure = (x >= 20) && (x <= 22.5) && (y >= 8.5) && (y <= 13.5);
  15.         boolean inside = insideFirstFigure | insideSecondFigure | insideThirdFigure;
  16.         String result = inside ? "Inside" : "Outside";
  17.         System.out.println(result);
  18.        
  19.         input.close();
  20.     }
  21.  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment