Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- /*
- * Name: Romario Coffie
- * Date: 10/9/2015
- * Course: CSC-111 Intro to Java Programming
- * Problem: 3.27
- * Description: Determine if point is in triangle
- * Email: Romario.agc@gmail.com
- */
- public class Angle{
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- System.out.println("Enter a value for X intercept then Y intercept.");
- Double xinter = input.nextDouble();
- Double yinter = input.nextDouble();
- System.out.println("Enter a values for a point, X then Y.");
- Double xval = input.nextDouble();
- Double yval = input.nextDouble();
- double m = -(yinter-0)/(xinter-0);
- double c = yval;
- if (xval<=xinter && yval <=yinter && xval>=0 && yval >=0){
- if ( xval <= (yval - c)/m)
- System.out.println("The point is in the triangle");
- else{
- System.out.println("The point is not in the triangle");
- }
- }
- else{
- System.out.println("The point is not in the triangle");
- }
- input.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement