Definitions:

equations::equations() { a = 0; b = 0; c = 0; } qEquations::qEquations(){} void equations::setVariables(float newa, float newb, float newc) { cout << "Based on the definition of the Quadratic formula above," << endl; cout << "please enter the value for the three variables." << endl; cout << "a = ?" << endl; cin >> newa; cout << "b = ?" << endl; cin >> newb; cout << "c = ?" << endl; cin >> newc; a = newa; b = newb; c = newc; } void qEquations::calculateNegative() { float temp; temp = sqrt((b*b)-(4*a*c)); cout << "The discriminant is " << temp << "." << endl; cout << "The value under the square root sign is " << (b*b)-(4*a*c) << "." << endl; if (temp < 0) { cout << "Cannot take the square root of a number equal-to or less-than 0." << endl; system("PAUSE"); exit (1); } else { cout << "The discriminant is " << temp << endl; negAnswer = (-b-temp)/(2*a); } } void qEquations::calculatePositive() { float temp; temp = sqrt((b*b)-(4*a*c)); posAnswer = (-b+temp)/(2*a); } void qEquations::printAnswer() const { cout << "The answer using the minus sign is " << negAnswer << endl; cout << "The answer using the plus sign is " << posAnswer << endl; }

Main:

#include "Header.h" float newa = 0; float newb = 0; float newc = 0; int main() { equations equation; qEquations qEquation; qEquation.setVariables(newa, newb, newc); qEquation.calculateNegative(); qEquation.calculatePositive(); qEquation.printAnswer(); system("PAUSE"); return 0; }

Header:

#include <iostream> #include <string> #include <cmath> using namespace std; class equations { public: void printIntro() const; void printEnd() const; void setVariables(float, float, float); equations(); protected: float a; float b; float c; }; class qEquations: public equations { public: void calculatePositive(); void calculateNegative(); qEquations(); void printAnswer() const; protected: float negAnswer; float posAnswer; };

**I have purposely left out the "Print Intro" and "Print End," they are just cout's explaning the project.