0

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.

  • It can be fixed by supplying the `getRootCount` and `solveEquation` functions; we have no way of knowing what or where they are. – Dave Newton Dec 09 '22 at 23:38
  • 2
    The code you've posted is incomplete, and we can't tell whether you did something wrong or whether your professor did. If you have issues with what was provided for your assignment or you don't understand it, contact your professor. They know what they gave you and what they expect, We don't. – Ken White Dec 09 '22 at 23:42
  • It would not surprise me if the professor is expecting you to implement `getRootCount()` and `solveEquation()` yourself as part of the assignment. – Remy Lebeau Dec 10 '22 at 03:12
  • You all are right, there was other code needed above main. Still haven't gotten it working but that was the roadblock – Nolan Van Schmus Dec 10 '22 at 08:04

0 Answers0