Guest User

Untitled

a guest
Mar 24th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. package net.ukr.shyevhen;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class HomeWorkL2E2 {
  6.  
  7. public static void main(String[] args) {
  8. Scanner sc = new Scanner(System.in);
  9. int x0;
  10. int y0;
  11. int x1 = 0;
  12. int y1 = 0;
  13. int x2 = 4;
  14. int y2 = 4;
  15. int x3 = 6;
  16. int y3 = 1;
  17. int a;
  18. int b;
  19. int c;
  20.  
  21. System.out.print("Enter coordinate x: ");
  22. x0 = sc.nextInt();
  23. System.out.print("Enter coordinate y: ");
  24. y0 = sc.nextInt();
  25. a = (x1 - x0) * (y2 - y1) - (x2 - x1) * (y1 - y0);
  26. b = (x2 - x0) * (y3 - y2) - (x3 - x2) * (y2 - y0);
  27. c = (x3 - x0) * (y1 - y3) - (x1 - x3) * (y3 - y0);
  28. if ((a <= 0 && b <= 0 && c <= 0) || (a >= 0 && b >= 0 && c >= 0)) {
  29. System.out.println("This point in the triangle.");
  30. } else {
  31. System.out.println("This point isn't in the triangle.");
  32. }
  33.  
  34.  
  35. }
  36.  
  37. }
Add Comment
Please, Sign In to add comment