//Coordinate Geometry
#include <iostream>
usingnamespace std;
int main()
{
double A1, B1, C1, A2, B2, C2; // coordinates
// display intro for user
cout<< "This program takes input values for two linear equations \n"
<< "and then calculates if they are equal, parallel, \n"
<< "perpendicular, and their intersection if it exists.\n"
<< "The standard equation of a line is Ax+By=C\n";
// get coordinates of line 1
tryAgain1:
cout << "Enter A, B, and C values for the First line\n";
cin >> A1 >> B1 >> C1;
if( A1==0 && B1==0 )
{
cout << "invalid line1. try again\n";
goto tryAgain1;
}
// get coordinates of line 2
tryAgain2:
cout << "Enter A, B, and C values for the Second line\n";
cin >> A2 >> B2 >> C2;
if( A2==0 && B2==0 )
{
cout << "invalid line2. try again\n";
goto tryAgain2;
}
if( A1/A2 == B1/B2 && A1/A2 == C1/C2)
cout << "they are same line\n";
if( A1/A2 == B1/B2 )
cout << "they are parallel\n";
if( A1*A2 + B1*B2 == 0 )
cout << "they are perpendicular\n";
double x, y;
if ( !(A1/B2==A2/B1) ) // not parallel
{
x= (B1*C2 - B2*C1) / (A1*B2 - A2*B1);
y= (C1*A2 - C2*A1) / (A1*B2 - A2*B1);
cout << "their intersection point is (" << x << ", " << y << ") \n";
}
return 0;
}