Question: I need help with this. Please help! #ifndef POLYNOMIAL _ ( H ) #define POLYNOMIAL _ ( H ) #include #include #include #include term.h

I need help with this. Please help! #ifndef POLYNOMIAL_(H) #define POLYNOMIAL_(H) #include #include #include #include "term.h" class Polynomial { public: ()/()*** Create a ba(d)/(i)nvalid polynomial of degree -1.* Arithmetic operations are not permitted on this bad value * and may cause a program to crash. Nonetheless, this value * is useful as a way of signalling invalid results.(*)/( P)olynomial(); ()/()*** Create a polynomial representing a linear or constant formula ax + b.(*)/( P)olynomial (int b, int a =0); ()/()*** Create a polynomial containing a collections of terms. * @param terms a set of terms(*)/( P)olynomial (std::initializer_(l)ist terms); ()/()*** Create a polynomial with the given coefficients. * E.g.,* double c[]={1,2,3}; * Polynomial p (3, c); * creates a polynomial p representing: 1+2*x +3*x^(2)** @param nCoeff number of coefficients in the input array * @param coeff the coefficients of the new polynomial, starting * with power 0.(*)/( P)olynomial (int nCoeff, int coeff[]); ()/()*** Get the coefficient of the term with the indicated power. * @param power the power of a term * @return the corresponding coefficient, or zero if power <0 or if * power > getDegree()(*)/( i)nt getCoeff(int power) const; ()/()*** The degree of a polynomial is the largest exponent of x with a * non-zero coefficient. E.g.,* x^(3)+2x +1 has degree 3*42 has degree 0(42==42* x^(0))*0 is a special case and is regarded as degree -1** @return the degree of this polynomial(*)/( i)nt getDegree() const; ()/()*** Add a polynomial to this one, returning their sum. ** @param p another polynomial * @return the sum of the two polynomials(*)/( P)olynomial operator+(const Polynomial& p) const; ()/()*** Multiply this polynomial by a scalar. * @param scale the value by which to multiply each term in this polynomial * @return the polynomial resulting from this multiplication(*)/( P)olynomial operator*(int scale) const; ()/()*** Multiply this polynomial by a Term. * @param Term the value by which to multiply each term in this polynomial * @return the polynomial resulting from this multiplication(*)/( P)olynomial operator*(Term term) const; ()/()*** Multiply this polynomial by a scalar, altering this polynomial. * @param scale the value by which to multiply each term in this polynomial(*)/( v)oid operator*=(int scale); ()/()*** Divide one polynomial by another, if possible. ** @param p the demoninator, the polynomial being divided into this one * @return the polynomial resulting from this division or the bad * value Polynomial() if p cannot be divided into this polynomial * to get a quotient polynomial with integer coefficients and no remainder.(*)/( P)olynomial operato(r)/()(const Polynomial& p) const; ()/()*** Compare this polynomial for equality against another. ** @param p another polynomial * @return true iff the polynomials have the same degree and their corresponding * coefficients are equal.(*)/( b)ool operator==(const Polynomial& p) const; private: ()/()*** @brief The degree of the polynomial. ** This is the largest power of x having a non-zero coefficient, or * zero if the polynomial has all zero coefficients.) Note that * adding polynomials together or scaling polynomials (multiplying by * a constant) could reduce the degree of the result. *(*)/( i)nt degree; dd(d)/(*)** List of terms, in ascending order of power. * Terms with zero coefficients are dropped. * An empty list of degree 0 is the polynomial: 0.(*)/( s)td::list terms;(()/())/( F)or example, the polynomial x^(2)+2x -1 would have:(()/())/( d)egree: 2(()/())/( t)erms: {Term(-1,0), Term(2,1), Term(1,2)}(()/())/(()/())()/() The polynomial 4x^(2)-12 would have:(()/())/( d)egree: 2(()/())/( t)erms: {Term(-12,0), Term(4,2)}(()/())/(()/())()/() The polynomial 42 would have:(()/())/( d)egree: 0(()/())/( t)erms: {Term(42,0)}(()/())/(()/())()/() The polynomial 0 would have:(()/())/( d)egree: 0(()/())/( t)erms: {}(()/())/(()/())()/() A special "bad" value used to signal an unsuccessful operations is(()/())/( d)egree: -1(()/())/( t)erms: {}*** A utility function to scan the current polynomial, putting it into * "normal form". In this case, the normal form will drop all terms with * zero coefficients, adjusting the degree as necessary. ** Polynomials should be kept in normal form at all times outside of the * actual member function bodies of this class.(*)/( v)oid normalize();(()/())/( A) "friend" declaration

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!