galinyotsev123

ProgBasicsJavaBook4.1ComplexConditions13PointInTheFigure

Jan 20th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class E13PointInTheFigure {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int h = Integer.parseInt(scanner.nextLine());
  8. int x = Integer.parseInt(scanner.nextLine());
  9. int y = Integer.parseInt(scanner.nextLine());
  10.  
  11. boolean isOutside = ((x < 0 || x > h * 3) && y <= h)
  12. || ((x < h || x > h * 2) && y > h)
  13. || (y < 0 || y > h * 4);
  14.  
  15. boolean isInside = (x > 0 && x < h * 3) && (y > 0 && y < h)
  16. || (x > h && x < h * 2) && (y > 0 && y < h * 4);
  17.  
  18.  
  19. if (isInside) {
  20. System.out.println("inside");
  21. }
  22. else if (isOutside) {
  23. System.out.println("outside");
  24. }
  25. else {
  26. System.out.println("border");
  27. }
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment