Project 14\3

The Projects

Project #13.1: A polynomial of degree n has the form:
a + bx + cx2 + ... + gxn-1 + hxn
The values a, b, c, ..., g, h are numeric constants called the coefficients of the polynomial, with h != 0. For example:
1 + 3x - 7x3 + 5x4
is a polynomial of degree 4 with integer coefficents of 1, 3, 0, -7 and 5. Design and implement a Polynomial class that can represent such a polynomial. Store the coefficients in a list instance variable of your class. Provide a constructor, an output operation that displays a Polynomial in easy-to-read format (i.e., using ^ to represent exponentiation), an input operation that allows a user a polynomial like that shown above, and an evaluate operation that given an x-value, returns the value of the polynomial for that value.

To test your class, write a program that reads a polynomial and values for x and displays the corresponding polynomial values.

Project #13.2: A limited number of complimentary copies of new CAD/CAM software will be released on a date to be announced. Requests for the software are to be filled in the order in which they are received. Write a program that reads the names and addresses of the persons requesting this software, together with the number of copies requested, and stores these in a linked list. The program should then produce a sequence of mailing labels (names, addresses, and number of copies) for requests that can be filled.

Project #13.3: Design and implement a BigInt class whose values are large integers with perhaps hundreds of digits. Represent each number as a list, each of whose elements is a block of digits of the big integer. Overload the addition and subtraction operators for this class. Do so by adding the lists value-by-value, carrying from one element to the next as necessary. Write a two-function BigInt calculator to test your program.

For some extra fun, overload the multiplication and division operators, too.

Project #13.4: Write a Print() library function template that, given a list, displays each value in the list on a separate line. Use an iterator as described in C++ An Introduction to Computing.

Add a Read() function template that, given a list, fills it with input values from the keyboard.

Using Print() and Read(), overload operator<< and operator>> with function templates so that list values can be read and displayed conveniently. Store these functions in the library as well.

Add a template for operator+ that, given two lists, returns the concatenation of the two lists. Then write a driver program that tests your functions.

Back to the Lab Exercise

Back to This Lab's Home Page

Report errors to Larry Nyhoff (