Question: C++ program. Separate as polymain.cpp, Polynomial.h, and Polynomial.cpp. Create a class called Polynomial for performing arithmetic with polynomials. In mathematics, a polynomial is an expression

C++ program. Separate as polymain.cpp, Polynomial.h, and Polynomial.cpp.

Create a class called Polynomial for performing arithmetic with polynomials. In mathematics, a polynomial is an expression consisting of variables and coefficients, that involves only the operations of addition, subtraction, multiplication, and non-negative integer exponents. A polynomial in a single variable x can always be written in the form: where are constants and x is the variable. 1. Class Polynomial must provide the followings: Constructors: Polynomial(double[] c, int degree); double c[] = {4, -5, 3.1 }; Polynomial poly(c); Polynomial(poly); Degree must be >= 0, else it is an error. Mutator/accessor: set(double[] a, int degree) new coefficients getCoefficients() return a copy of the coefficients getDegree() return the degree (inline) Functions: == : compare polynomials bool same = p1 == p2; cin >> poly degree coefficients cout << poly outputs "3.1x^2 5x + 4" f(double x) evaluate and return the value of the polynomial + : Polynomial p3 = p1 + p2; polynomial addition, where p1 and p2 are Polynomials, returns a polynomial. 2. Provide a main function to show the use of the class (polymain.cpp). 3. Provide the definition and implementation files (Polynomial.h and .cpp). Do not use any inline implementations except getDegree. Memory must be allocated and deallocated properly.

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 Databases Questions!