### design a class that can be used to represent a parabola, any help is greatly appreciated

First off thank you for taking out time on even thinking of helping me.

So i've been up for way too long and having massive brain farts. The goal of this program is to have output like this:

The first parabola:

1.0x^2 + 4.0x + -5.0

Vertex Coordinates: (-2.000, -9.000)
The parabola opens UPWARD
There are two real roots with X-Coordinates 1.000 and -5.000

The numbers for the parabola need to be entered in main, calcRoots (it just needs to be squared somewhere) my void Parabola:: print() section needs help as well. I'm not sure how to go about either.
Heres what I have so far. the first is my header file i called hw9.h

 ``123456789101112131415161718192021222324252627`` ``````#include //getting info from various libraries #include #include #include #include using namespace std; class Parabola { public: Parabola( double, double, double ); double calcDiscrim(); double calcRoots( double &, double & ); double calcX(); double calcY(); void printEquation(); void printVertex(); void printRoots(); void printConcavity(); void print(); private: double aCoeff, bCoeff, cCoeff; }; ``````

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113`` `````` #include "hw9.h" Parabola::Parabola(double a, double b, double c) { aCoeff = a, bCoeff = b, cCoeff = c; if(a == 0) aCoeff = 1; if(b == 1) bCoeff = 2; if(c == 2) cCoeff = 3; } double Parabola::calcDiscrim() { return (bCoeff * bCoeff - 4 * aCoeff * cCoeff); } int Parabola::calcRoots( double &root1, double &root2 ) //needs work. what does multiplicity 2 means squared? { int numRoots=0; double discriminant=calcDiscrim(); else if (discriminant ==0) { root1 = ( (-1*bCoeff) + sqrt( discriminant )) / ( 2 * aCoeff ); numRoots=1; } else if(discriminant > 0)) { root1 = ( (-1*bCoeff) + sqrt( discriminant )) / ( 2 * aCoeff ); root2 = ( (-1*bCoeff) - sqrt( discriminant )) / ( 2 * aCoeff ); numRoots=2; } return numRoots; } double Parabola::calcX() { return(-1*bCoeff / ( 2 * aCoeff)); } double Parabola::calcY() { double Xcord=calcX(); return(( aCoeff * (Xcord*Xcord) ) + ( bCoeff * Xcord ) + cCoeff); } void Parabola::printEquation() { cout<0) cout<<"The parabola opens UPWARD"; else cout<<"The parabola opens DOWNWARD"; } void Parabola:: print() { }``````
Last edited on
Topic archived. No new replies allowed.