Answered You can hire a professional tutor to get the answer.

QUESTION

// poly.h - class Poly represents polynomials as a linked list // DO NOT EDIT THIS FILE - you will not turn it in. #ifndef POLY_H #define POLY_H...

POLY.CPP// poly.cpp - implements class Poly// YOUR NAME(S) AND THE DATE#include "poly.h"#include <cmath> // to use pow in valueAt and fabs in print#include <iostream>using namespace std;/*** SOLUTION HERE: SEE INSTRUCTIONS ***//*** PART OF ASSIGNMENT SKELETON BELOW - DO NOT CHANGE ***/// prints p (e.g, "25.2x^4 + 7.1x^2 - 4x + 2.3")void Poly::print() const {Term *t = first;if (t == NULL) {cout << "0";return;}// print first termif (t->coeff < 0)cout << "-";printAbsTerm(t);// loop through and print remaining termsfor (t = t->next; t != 0; t = t->next)if (t->coeff > 0.) {cout << " + ";printAbsTerm(t);}else {cout << " - ";printAbsTerm(t);}}// utility used by printPoly - prints absolute value of one term;// assumes t is not nullvoid Poly::printAbsTerm(Term *t) const {double absCoeff = fabs(t->coeff);if (absCoeff != 1. || t->exponent == 0)cout << absCoeff;if (t->exponent == 1)cout << "x";else if (t->exponent != 0)cout << "x^" << t->exponent;}Complete poly.cpp to implement a class that represents polynomials, as described below. Specifically, implement the functions of class Poly as they are declared in poly.h. Start with this skeleton, and type your name(s) and the date the program is written in the header comment. Implement the eight required member functions (the constructor and print function are done already) as follows - type your solution between the two C-style comments in the skeleton: addTerm - adds a term to the polynomial - either by changing the coefficient of an existing term (which might require deleting the term if its coefficient becomes zero), or by inserting a new term; maintains the terms in order from greatest to least exponent. Note: addTerm is the most difficult function, but it is also the most important as it can be used to implement other functions more easily. valueAt - returns the double value of the polynomial at the value of the parameter. degree - returns degree of the polynomial (greatest exponent value). count - returns the number of terms in the polynomial. plus - returns a polynomial that is equal to "this" polynomial plus the parameter polynomial. minus - returns a polynomial that is equal to this polynomial minus the parameter polynomial. times - returns a polynomial that is equal to this polynomial times the parameter polynomial. clear - deletes all terms in this polynomial's list of terms, and sets first to 0. Note - assume that an empty list indicates a polynomial equal to zero.

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question