The descriminant value shows up but the roots do not output. Any thoughts?
Heres the problem specifications.
Function poly(given x, z, a, b, c; returns y)
Function roots(given degree, left, right, z, a, b, c, &secondRoot; returns estimateOfRoot)
Note: The roots function has a switch structure to process either a polynomial of degree 2 or 3 with case 2: to handle quadratic formula that returns two roots, one through the normal return statement via estimateOfRoot and a second root through the reference parameter &secondRoot; and with case 3: to handle the cubic polynomial with the incremental search technique.
Your main module should drive the roots function with PIE from the user for degree, coefficients, interval limits, and step size until the user decides to quit the program with a value of -1 for degree, that is, an input sentinel of -1 to terminate a loop in the main module that drives your Polynomial Roots Problem.
Main FUNCTION
#include "head.h"
int main()
{//start main
double a = 0, b = 0, c = 0, z = 0, stepsize = 0, leftbound = 0, rightbound = 0, secondroot = 0, root = 0;
int degree = -1;
cout << "Enter the desired degree(2 or 3) or type (-1) to quit: ";
cin >> degree;
while(degree != -1)
{
while((degree != 2) && (degree != 3))
{
cout << "\nThis is not an option." << endl;
cout << "Enter the desired degree (2 or 3): ";
cin >> degree;
}
cout << "\nEnter a, b, c, and z: ";
cin >> a;
cin >> b;
cin >> c;
cin >> z;
if(degree == 3)
{
cout << "\nPlease enter the step size, right bound, and left bound: ";
cin >> stepsize;
cin >> rightbound;
cin >> leftbound;
}
if (degree == 2)
{//start if
if (root != -9999)
{//start inner if
cout << "Root 1 is: " << root << endl;
cout << "Root 2 is: " << secondroot << endl;
}//end inner if
else
{//start else
cout << "Root 1 is an imaginary and can not be calculated" << endl;
cout << "Root 2 is an imaginary and can not be calculated" << endl;
}//end else
}// end if
cout << "\nEnter the desired degree (2 or 3) or type (-1) to quit: ";
cin >> degree;
}//end while
}// end main
Poly.cpp FUNCTION
double poly(double x, double z, double a, double b, double c)