The main() below was given to my class by the professor with the objective of making the program into a sentinel loop but he claims that the program will run as a one off with copy paste but "getRootCount" and "solveEquation" are flagging and it won't work. I haven't been able to find anything on how to fix this problem. I am using Visual Studio which he also supposedly uses as well.
int const SIZE = 3;
double coefficients[SIZE];
double discriminant;
cout << "This program solves quadratic formulas\n";
cout << "Enter 3 coefficients separate by spaces: ";
cin >> coefficients[0] >> coefficients[1] >> coefficients[2];
if (coefficients[0] == 0)
cout << "First coefficient cannot be 0.";
else
{
// Get number of roots
int rootCount = getRootCount(discriminant, coefficients);
if (rootCount == 0) // No root
cout << "There is no root" << endl;
else // 1 or 2 roots
{
double roots[2];
solveEquation(discriminant, coefficients, roots);
if (rootCount == 1)
cout << "There is one root: " << roots[0] << endl;
else
cout << "There are 2 roots: " << roots[0] << " " << roots[1] << endl;
}
}
I've googled it and as far as I can tell "getRootCount" and "solveEquation" aren't actually commands. If that's true I'm not sure what to use instead.