# A C++ implementation of a polynomial class.

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.
6. Add a multiplication operation to you Polynomial class.

This question has the following supporting file(s):

• p1.doc
###### File Viewer (Click To Zoom)

Solution Summary

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

\$2.19
• Plain text
• Cited sources when necessary
• Attached file(s)
• main.cpp
• polynomial.cpp
• polynomial.h

Mike Noel, MS

Rating 4.9/5

Active since 2007

BS, Willamette University

Responses 241

"Thank you, Can you help me with posting# 543565?"

"Thank you very much... I now get the beginings of hashtables. I will finish going over these for the next few days and if I have any more questions I will come back."

"I enjoyed the details explanations to what you did. Can I save you for future refernces?"

"Thank you very much will you be online for a while?"

"Great explanation. Thank you"

Extracted Content from Question Files:

• p1.doc

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

a2 x 2 ... a n x n
a0 a1 x

Where a 0 , a1 ,...., a n are numeric constants called the coefficients of the polynomial and an #0.

For example:

3x - 7 x3 5x4
1

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 x n 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.