Explore BrainMass

A C++ implementation of a polynomial class.

This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

Do this exercise in C++ language, prefer use Visual C++ or DevC to compile.

Exercise 6.3: A polynomial of degree n has the form

Where are numeric constants called the coefficients of the polynomial and #0.

For example:

is a polynomial of degree 4 with integer coefficients 1, 3, 0, -7 and 5. One common implementation of a polynomial stores the degree of the polynomial and the list of coefficients. This is the implementation to be used in the exercises that follow. As you add the various operations to the Polynomial class you are building, you should also write a program to test your class.

1. Write a declaration for a Polynomial class whose data members are an integer for the degree and an array for the list of coefficients and with basic operations of input and output.
2. Implement the input operation in Question 1
3. Implement the output operation in Question 1. Display the polynomial in the usual mathematical format with displayed as x^n.
4. Add an evaluate operation to your Polynomial class that allows the user to enter a value for x and that calculates the value of the polynomial for that value.
5. Add an addition operation to your Polynomial class.
6. Add a multiplication operation to you Polynomial class.

© BrainMass Inc. brainmass.com March 21, 2019, 5:28 pm ad1c9bdddf


Solution Preview

This solution revolves around the creation of a C++ class that
implements a polynomial. The class contains two data members: degree,
and coefficients. The degree indicates the degree of the polynomial
as described in ...

Solution Summary

This solution provides a C++ class that implements a polynomial and the common polynomial functions.