Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that prompts the user to enter a point with x and y coordinates an determines wether the point is inside the triangle

Write a program that prompts the user to enter a point with x and y coordinates an determines wether the point is inside the triangle

the right triagle points are : (0,0) ,(200,0) , (0,100)

Here is what I did but he program is not running

#include

#include

float area (int, int, int, int, float, float);

bool islnside(int, int, int, int, float, float);

using namespace std;

int main()

{

float a, b, c, d, x1, x2, x3, x4, y1, y2, y3, y4;

x1 = 0;

y1 = 0;

x2 = 200;

y2 = 0;

x3 = 0;

y3 = 100;

cout << "Enter point (x,y): ";

cin >> x4;

cin >> y4;

if (islnside(0, 0, 200, 0, 0, 100, x4, y4))

cout << "The point (

else

cout << "The point ( < Triangle";

return 0;

}

bool islnside(int x1, int y1, int x2, int y2, int x3, int y3, float a, float b)

{

float a = area(x1, y1, x2, y2, x3, y3);

float a1 = area(x2, y2, x3, y3, a, b);

float a2 = area(x1, y1, x3, y3, a, b);

float a3 = area(x1, y2, x2, y2, a, b);

return(a == a1 + a2 + a3);

}

float area(int x1, int y1, int x2, int y2, float x3, float y3);

{

return abs((x1*(y2 - y3) + x2*(y3 - y1) + x3*(y1 - y2)) / 2.0);

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Richard T. Watson

2nd Edition

0471180742, 978-0471180746

More Books

Students also viewed these Databases questions

Question

1. Write down two or three of your greatest strengths.

Answered: 1 week ago