(algebra:solving linear equations) You can use Cramer's rule to solve the following 2*2 system of linear equation:
a*x+b*y=e
c*x+d*y=f
x=e*d-b*f/a*d-b*c
y=a*f-e*c/a*d-b*c
write a program that prompts the user to enter a, b, c, d, e, and f. and display the result. if ad-bc is 0, report that "The equation has no solution."
#include <iostream>
usingnamespace std;
int main ()
{
double x;
double y;
double a,b,c,d,e,f;
cout << "Enter a, b, c, d, e, f: "; // Ask the user to enter the 6 numbers
cin >> a >> b >> c >> d >> e >> f ; // enter the numbers
if (a*d-b*c == 0)
{
cout << " The equation has no solution." << endl;
}
else
{
x = (e*d-b*f)/(a*d-b*c);
y = (a*f-e*c)/(a*d-b*c);
cout << " x is: " << x <<"and y is: " << y << endl;
}
return 0;
}