CSCI 235 Software Analysis & Design Spring, 2003
Instructor: Szenher
Programming Assignment #4: Polynomials
Due Date: March 24, 2003
Objectives: This program will allow you to build and manipulate linked lists
Problem Specification: You will design and implement a class to represent a polynomial in x (e.g. x3+3x+3). Your class will allow a client to perform a wide range of operations on a given polynomial; these operations are detailed below, in the implementation section.
Implementation: You will design (using ADTs with UML) and implement two classes: Polynomial and Term.
The Term class will be used to represent each term in a polynomial. In the polynomial x3+3x+3, x3, 3x, and 3 are each terms. You may assume that term coefficients and exponents are integers.
The Polynomial class, as it's name suggests, will represent an entire polynomial. Your Polynomial class must store a polynomial as a linked list of terms. You must include the following operations in the Polynomial class interface:
Required Testing:
Use the following as the Polynomial class client:
CPolynomial p1 ("3*x^2+40*x^1+203*x^0+35*x^1");
CPolynomial p2 ("1*x^3+1*x^4+2*x^2+1*x^0");
p1.Print(cout);
cout << endl;
p2.Print(cout);
cout << endl;
cout << p1.Evaluate(0)<< endl;
p1.Graph (cout, 0, 10);
p1.AddPolynomial(p2);
p1.Print(cout);
cout << endl;
p2.Print(cout);
cout << endl;
The following output should be produced:
3*x^2+75*x^1+203*x^0
1*x^4+1*x^3+2*x^2+1*x^0
203
p(0)=203
p(1)=281
p(2)=365
p(3)=455
p(4)=551
p(5)=653
p(6)=761
p(7)=875
p(8)=995
p(9)=1121
p(10)=1253
1*x^4+1*x^3+5*x^2+75*x^1+204*x^0
1*x^4+1*x^3+2*x^2+1*x^0
Extra Credit: