Question: Based on the sample output provided, and the polynomial.h and task-2.3.cpp files shown below, implement the required member functions and non-member function in your polynomial.cpp

 Based on the sample output provided, and the polynomial.h and task-2.3.cppfiles shown below, implement the required member functions and non-member function inyour polynomial.cpp file. Write a class Polynomial that stores a polynomial such

Based on the sample output provided, and the polynomial.h and task-2.3.cpp files shown below, implement the required member functions and non-member function in your polynomial.cpp file. Write a class Polynomial that stores a polynomial such as p(x) = 5x^10 + 9x^7 - x - 10 as a linked list of terms. A term contains the coefficient and the power of x. For example, you would store p(x) as (5, 10), (9, 7), (-1, 1), (-10, 0) We allow decimal numbers such as4.5 and 6.78 etc to be used as coefficients. Function get_pts (xStart, xEnd, xStepSize): The member function get_pts() calculates and returns a queue of x, y coordinate pairs. They coordinate is calculated from the Polynomial's equation based on the passed parameters of: xStart to xEnd with an increment of xStepSize. Function plot(coords): The non-member function plot() provides a formatted printout of the x, y coordinates returned by the get_pts() function. See sample output provided. polynomial.h #ifndef POLYNCMIAL_H #define POLYNCMIAL_H #include #include #include using namespace std: class Polynomial { public: Polynomial(): Polynomial(pair ): void add(Polynomial p): void add_term(pair t): queue > get_pts(double, double, double): void print(): private: list > terms: }: void plot(queue >): #endif task-2.3.cpp #include #include #include #include #include #include "polynomial.h" int main() { queue > pts;//Coords //2x^3 - 3x^2 -3x+2 Polynomial p(pair (2, 3)): p.add(Polynomial(pair (-3, 2))): p.add(Polynomial(pair (-3, 1))): p.add(Polynomial(pair (2, 0))): //Print the Polynomial p print(): //Calculate x, y coordinates for the Polynomial //from xStart to xEnd with xStepSize pts = p.get_pts (-1.5, 2.5, 0.5): //Print x, y coords plot (pts): return 0: } Sample output: C: \csc2401 > g++ -Wall task-2.3.cpp polynomial.cpp C: \csc2401 > a + 2 -3*x -3*x^2 + 2*x^3

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!