Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9227325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:02:44+00:00 2026-06-18T05:02:44+00:00

I have been on this for hours, attempting different methods looking at just about

  • 0

I have been on this for hours, attempting different methods looking at just about every question. Perhaps I have it completely wrong, but I feel that I have my math of it correct, but no matter what numbers I input, I get the same output. My code is off somewhere and I have to turn it in by midnight.

It is the all so fun: Find if a point is within a triangle code. (for beginners)

import java.util.Scanner;

public class PointsTriangle {

    // checks if point entered is within the triangle
    //given points of triangle are (0,0) (0,100) (200,0)
    public static void main (String [] args) {
        //obtain point (x,y) from user
        System.out.print("Enter a point's x- and y-coordinates: ");
        Scanner input = new Scanner(System.in);
        double x = input.nextDouble();
        double y = input.nextDouble();

        //find area of triangle with given points
        double ABC = ((0*(100-0  )+0*(0  -0)+200*(0-100))/2.0);
        double PAB = ((x*(0  -100)+0*(100-y)+0  *(y-  0))/2.0);
        double PBC = ((x*(100-0  )+0*(0  -y)+200*(y-100))/2.0);
        double PAC = ((x*(0  -100)+0*(100-y)+200*(y-  0))/2.0);

        boolean isInTriangle = PAB + PBC + PAC == ABC;

        if (isInTriangle)
            System.out.println("The point is in the triangle");
        else
            System.out.println("The point is not in the triangle");
    }//end main
}//end PointsTriangle
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T05:02:45+00:00Added an answer on June 18, 2026 at 5:02 am

    If you draw a picture, you can see the point has to satisfy simple inequalities (below / above / to the right of certain lines). Whether “on the edge” is in or out I will leave up to you:

    Y > 0 (above the X axis)
    X > 0 (to the right of the Y axis)
    X + 2* Y < 200 (below the hypotenuse)
    

    Write an if statement around these three and you’re done:

    if( (y > 0) && (x > 0) && (x + 2*y < 200) ) 
      System.out.println("The point is in the triangle");
    else
      System.out.println("The point is not in the triangle");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Been struggling with this for about 4 hours, I'm attempting to have a modal
Have been working on this question for a couple hours and have come close
I have been at this for hours and I have no idea what's wrong.
I have been looking at this for hours and can't figure this out. If
Hey I have been looking all over the internet and this site for hours
I have been wrestling with this for hours and just can't make it work.
I have been looking into this for hours and still at a loss. I
I have been trying this for hours without success. http://replicaisland.googlecode.com/svn/trunk/ I have added the
I Have been fiddling with this for hours. I can not get my text
Okay. Now I give up. I have been playing with this for hours. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.