Topical Information

The purpose of this project is to test your ability to use dynamic memory (mixed with classes), operator overloading, and libraries effectively in program design.

Program Information

Create a class for an algebraic formula in a single variable. As a reminder, such a formula has the form:

      n        n-1          2      1      0
   a x  + a   x    + ... a x  + a x  + a x
    n      n-1            2      1      0


    \      i
     >  a x
    /    i

(Same formula, different format...)

Construct the formula from the variable name (char or String?) and the number of terms. Overload subscript to allow your user to set/access the coefficients. (Coefficients should start as 0 by default.)

Overload output to print the formula as neatly as possible (you won't need the subscripts; you may use ^ instead of the superscripts). Ignore input for now...that can get pretty twisted.

Overload addition to add two such formulas (if you take the variable name into account, adding two formulas in different variables should result in an empty formula; that's a head-ache we don't need right now) — element-wise add the coefficients (a0 of the first formula plus a0 of the second formula). You should be able to add formulas with a different number of coefficients.

Overload multiplication between a formula and a scalar (single real number value) so that the programmer can multiply either 'scalar * formula' or 'formula * scalar'. The result (either way) should be the scalar multiplied element-wise by all the coefficients.

Addition, subtraction, and division by a scalar should be done as well. (You may find having an operator - in unary form handy for the subtraction implementation...*wink,wink* *nudge,nudge* Say no more...) (Warning! 'formula / scalar' is well defined, but 'scalar / formula' is way beyond the scope of this programming assignment!)

While overloading assignment, do +=, -=, *=, and /= similarly to above.

Include any other constructors, destructors, or methods that seem necessary/useful. (Maybe one for returning the order — highest power — of the formula would be nice. And for returning the variable name? *shrug*)

Write a driver to show off your formula class' abilities.

This assignment is (Level 6) before options.