Advertisement
Guest User

Untitled

a guest
Jan 25th, 2015
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. import java.util.Locale;
  2. import java.util.Scanner;
  3.  
  4.  
  5. public class _09_PointsInsideTheHouse {
  6. public static void main(String[] args) {
  7. @SuppressWarnings("resource")
  8. Scanner str = new Scanner(System.in);
  9. double a = str.useLocale(Locale.US).nextDouble();
  10. double b = str.useLocale(Locale.US).nextDouble();
  11.  
  12. double aX = 12.5f;
  13. double aY = 8.5f;
  14. double bX = 22.5f;
  15. double bY = 8.5f;
  16. double cX = 17.5f;
  17. double cY = 3.5f;
  18.  
  19. double ABC = Math.abs(aX * (bY - cY) + bX * (cY - aY) + cX * (aY - bY));
  20. double ABP = Math.abs(aX * (bY - b) + bX * (b - aY) + a* (aY - bY));
  21. double APC = Math.abs(aX * (b - cY) + a * (cY - aY) + cX * (aY - b));
  22. double PBC = Math.abs(a * (bY - cY) + bX * (cY - b) + cX * (b - bY));
  23. boolean inTriangle = ABC == ABP + APC + PBC;
  24.  
  25. if ((a >= 12.5 && a <= 17.5 || a >= 20 && a <= 22.5) && b >= 8.5 && b <= 13.5 || inTriangle) {
  26. System.out.println("Inside");
  27. }
  28. else {
  29. System.out.println("Outside");
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement