A C++ implementation of a polynomial class.
Exercise 6.3: A polynomial of degree n has the form
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.
This question has the following supporting file(s):
This solution provides a C++ class that implements a polynomial and the common polynomial functions.
This answer includes:
- Plain text
- Cited sources when necessary
- Attached file(s)
Active since 2007