Hey my program works fine when finding the equation of the line the first 2 points lie one, but prints nothing to the screen after the third point is entered. I think it may be the if statements; please help it would be much appreciated.
#include <iostream>
usingnamespace std;
int main()
{
double x1, y1, x2, y2, x3, y3, m, b;
cout << "Enter the x y coordinates for point one (e.g. 0.5 1.7):";
cin >> x1 >> y1;
cout << "Enter the x y coordinates for point two: ";
cin >> x2 >> y2; //Calculate slope and y-intercept
//slope = rise over run
m = (y2 - y1)/(x2 - x1);
//line equation is y = m*x + b, so rearrange to get y-intercept b = m*x - y( not true b = y- mx).
//this is true for all points, so it must be true for x1 y1
b = y1 - m*x1;
cout << "Your two points lie on the line" <<"y = " << m <<"x + " << b << endl;
//get a third point from user
cout << "Enter the x y coordinates for point three: ";
cin >> x3 >> y3;
// where i think it stops working
if( y3 = m*x3 + b )
{ cout << "Point three also lies on the line " <<"y = " << m <<"x + " << b;
//this will lie on the line if y3 = m*x3 + b
}
elseif ( y3 != m*x3 + b)
{ cout << "Point three does not lie on the line" <<" y = " << m <<"x + " << b;
}
return 0;
}