CS210
Fall 2007
Programming Project 1
Date: Friday, September 28, 2007.
Due:
A polynomial of degree n has the form
a0 + a1 x + a2x2
+ … + an xn
where a0, a1, …, an
are numeric constants called the coefficients of the polynomial and an
!=0. For example,
1
+ 3x – 7x3 + 5x4
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 (in order).
This is the implementation to be used in the exercises that follow.
Work in groups of 2-3 students to:
1. Build a complete List class, using a array-based
implementation, as described in class. For basic operations it should have a
constructor, destructor, copy constructor, assignment and the basic list
operations: empty, traverse, and insert.
2. Write a declaration for the polynomial class whose data members are
an integer for the degree and an array for the list of coefficients with basic
operations for input, addition, evaluation and output.
3. Implement the input operation in exercise 2.
4. Implement the output operation in exercise 2. Display the polynomial
in the usual mathematical format with xn
displayed as x^n.
5. Add an addition operation to the polynomial class.
6. Implement the evaluate operation that allows the user to enter a
value for x and that calculates the value of the polynomial for that value.
7. Use the Polynomial class developed above in a menu-driven program
for processing polynomials. Options on the menu should include reading a
polynomial, printing a polynomial adding two polynomials and evaluating a
polynomial for a given value for the variable.