Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Omar Natour
- * 10/9/2015
- * Csc-111-D01
- * Problem 3.27
- * Determine whether a point is inside or outside of a predetermined triangle.
- * ojnatour0001@student.stcc.edu
- */
- import java.util.Scanner;
- public class HW4 {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- System.out.print("Enter the value of a point (x,y).\nX:");
- double x = input.nextDouble();
- System.out.print("Y:");
- double y = input.nextDouble();
- input.close();
- if (x >= 0 && y >= 0) {
- double pos = 200 * (y - 100) - x * -100;
- if (x == 0 || y == 0 || pos == 0)
- System.out.print("The point (" + x + ", " + y + ") is on the line of the triangle.");
- else if (pos < 0)
- System.out.print("The point (" + x + ", " + y + ") is in the triangle.");
- else
- System.out.print("The point (" + x + ", " + y + ") is not in the triangle.");
- } else
- System.out.print("The point (" + x + ", " + y + ") is not in the triangle.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement