/****************************************************************************** Lab Exercise #5 -- Implementation of driver module ******************************************************************************/ using namespace std; #include #include #include "lab05.support.h" extern int InputStatus; /*----------------------------------------------------------------------------- Name: main Purpose: Compute the roots of a quadratic equation. -----------------------------------------------------------------------------*/ int main() { int RootStatus; double A, B, C, Root1, Root2; cout << setiosflags( ios::fixed ) << setprecision( 1 ); for (;;) { InputStatus = 0; coefficients( A, B, C ); if (InputStatus == 0) break; RootStatus = roots( A, B, C, Root1, Root2 ); cout << endl << "The equation:" << endl << endl; cout << " " << A << " x^2 + " << B << " x + " << C << endl; switch (RootStatus) { case 0: cout << endl << "has the following roots:" << endl << endl; cout << " root 1 = " << Root1 << endl; cout << " root 2 = " << Root2 << endl << endl; break; case 1: cout << endl << "has the following root:" << endl << endl; cout << " root = " << Root1 << endl << endl; break; case 2: cout << endl << "has complex roots." << endl << endl; break; case 3: cout << endl << "is not quadratic." << endl << endl; break; } } }