Question: (Algebra: solve 2 2 linear equations) You can use Cramers rule to solve the following 2 2 system of linear equation: ax + by =

(Algebra: solve 2 2 linear equations)

You can use Cramers rule to solve the following 2 2 system of linear equation:

ax + by = e

cx + dy = f

x = (ed - bf) / (ad - bc)

y = (af - ec) / (ad - bc)

Write a function with the following header:

void solveEquation(double a, double b, double c, double d,

double e, double f, double& x, double& y, bool& isSolvable)

If ad - bc is 0, the equation has no solution and isSolvable should be false.

Write a program that prompts the user to enter a, b, c, d, e, and f and displays the result.

If ad - bc is 0, report that The equation has no solution.

This is what I have so far:

#include #include

using namespace std;

void solveEquation(double a, double b, double c, double d, double e, double f, double& x, double& y, bool& isSolvable) // Ask the user to enter the 6 numbers

cout << "Enter a: "; cin << a; cout << "Enter b: "; cin << b; cout << "Enter c: "; cin << c; cout << "Enter d: "; cin << d; cout << "Enter e: "; cin << e; cout << "Enter f: "; cin << f;

if (a*d - b * c == 0) { isSolvable == 0; cout << " The equation has no solution." << endl; } else { isSolvable == 1; 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; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!