This is code for the slope intercept formula y = mx + b
I am supposed to find the slope (y2 - y1) / (x2 - x1) and have the user input the b for the y = mx + b in my program. Once the user does that I do the same exact thing again so I can compare if the lines intersect or not.
the only problem with my code is that I am getting an unresolved external. Can anyone help me out??
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int Line1();
int Line2();
void solution_identifier();
void Results();
int Line1()
{
float x, y, x2, y2;
float Y_intercept;
cout << "Please enter your coordinate points begining with x: ";
cin >> x;
cout << "Now enter your Y coordinate point: ";
cin >> y;
cout << "Now your X2 coordinate point: ";
cin >> x2;
cout << "Finally your Y2 coordinate point: ";
cin >> y2;
float slope((y2 - y) / (x2 - x));
cout << slope << "X is your slope." << endl;
cout << "Please enter the Y intercept, which would be the b in the slope-intercept formula, from your 1st formula: ";
cin >> Y_intercept;
return 0;
}
int Line2()
{
float a, c, a2, c2;
float Y_intercept2;
cout << "Please enter your coordinate points begining with a: ";
cin >> a;
cout << "Now enter your c coordinate point: ";
cin >> c;
cout << "Now your a2 coordinate point: ";
cin >> a2;
cout << "Finally your c2 coordinate point: ";
cin >> c2;
float slope2((c2 - c) / (a2 - a));
cout << slope2 << "X is your slope." << endl;
cout << "Please enter the Y intercept from your 2nd formula: ";
cin >> Y_intercept2;
return 0;
}
void solution_identifier(float slope, float slope2, float Y_intercept, float Y_intercept2)
{
if (slope == slope2 && Y_intercept == Y_intercept2)
{
cout << "The two lines intersect forever meaning there are an infinite number of solutions." << endl;
}
else
if (slope == slope2 && Y_intercept != Y_intercept2)
{
cout << "The two lines are paralell which means there are no solutions." << endl;
}
else if (slope != slope2)
{
cout << "The two lines intersect which means there is only one solution." << endl;
}
}
void Results(float slope, float slope2, float Y_intercept, float Y_intercept2)
{
cout << "The slope of line 1 is: " << slope << endl;
cout << "and it's Y intercept is: " << Y_intercept << endl;
cout << "The slope of line 2 is: " << slope2 << endl;
cout << "and it's Y intercept is: " << Y_intercept2 << endl;
}
int main(float x, float y, float x2, float y2, float a, float c, float a2, float c2, float Y_intercept, float Y_intercept2)
{
cout << "Quick Note: Any user interacting with this part of the program should be aware" << endl;
cout << "it is assumed that your formula is in the slope-intercept form(Y = mX + b)." << endl;
Line1();
Line2();
Results();
solution_identifier();
system("PAUSE");
return 0;
}