Open Book: 2 Hours
January, 13 2003
Name: _________________________
ID: __________________________
Solve Three out of the Following Four Problems
1.
Develop
a class
Polynomial
which should contain as member variables an array of
coefficients. The value of an array element would represent the coefficient and the index
would represent the corresponding exponent. For example, to represent term 3
x
2
in a
polynomial the value 3 would enter at index 2 of the array. Consider that the highest
polynomial order is 20. Develop constructors for the class and a utility function that will
evaluate the value of a polynomial of
x
for a given
x
. Test the class using simple first and
second order polynomials. Provide the following
overloaded operator
capabilities:
a)
Overload the
addition
operator (
+
) to add two polynomials
b)
Overload the
subtraction
operator (
–
) to subtract two polynomials
c)
Overload the
assignment
operator (
=
) to assign one polynomial to another
d)
Overload the
multiplication
operator (
*
) to multiply two polynomials.
e)
Overload the
insertion
(<<) operator to print the form of a polynomial, for
example as:
3x2 – 2x + 1
2.
Write
a program that inputs a numeric check amount and write the word equivalent of it.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 Fall '07
 SAMIKARAKI
 Subroutine, Prime number, operator overloads

Click to edit the document details