IUP Computer Science
CO 310 Spring 1993

Assignment #3
(Due   12 March 1993)



    A program to do simple manipulation of polynomials is to be written.  The program is command oriented, using one letter commands to indicate which actions are to be performed.  Each action must be performed by a procedure (name shown Bold below).   The command letters and their purpose follow.

Command   Action
     M         Make a polynomial.
The procedure must read in pairs of exponents and coefficients (each pair represents one term in the polynomial) until a pair of -1's are read. The reading is from the keyboard.  The procedure stores a pointer to the polynomial in the next available element of the PolyGroup.  The procedure displays the entry number in the PolyGroup; this is referred to as the polynomial's PolyNumber.  The procedure also displays the created polynomial.

     A         Add two polynomials creating a new polynomial.
The new polynomial has a pointer to it stored in the next available element of the PolyGroup.  The PolyNumbers of the two polynomials being added are parameters for the procedure.  The procedure displays the PolyNumber of the new polynomial, as well as the sum polynomial. ***** This command is optional *****

     D         Takes the Derivative of a polynomial
creating a derivative polynomial which has a pointer to it added to the PolyGroup.  The PolyNumber of the original polynomial is a parameter.  The procedure displays the new PolyNumber, as well as the derivative polynomial.

     C         Clear a polynomial.
The PolyNumber of a polynomial is the parameter for the procedure.  The procedure deletes the entry from the PolyGroup and destroys the polynomial.

     E         Evaluate a polynomial at a data point.
The procedure takes the PolyNumber, the data point, and the result as parameters.

     S         Calculate the Slope of a tangent line at a data point.
The procedure takes the PolyNumber, the data point, and the result as parameters.  Note:  calculation of the slope requires evaluating the derivative polynomial at the specified point.

     P         Print a polynomial.
The procedure takes the PolyNumber as a parameter.

    I have written the main program for this assignment.  My source code is in the file L:\310\MAIN3.PAS.  My program relies on you to write a UNIT called POLY that defines the procedures for the commands described previously (as well as any other procedures and/or functions you may need).  You must meet the following requirements for your UNIT.

1.  You must implement the storage of each polynomial as a linear    linked list with a header node or as a circular linked list    without header node.  Nodes similar to those used in class    should be used.

2.  Your UNIT must define appropriate user-defined types for    storing the polynomial and the group of pointers (PolyGroup).    Your definitions should NOT be visible to the main program.    Implementation of the PolyGroup is up to you; but you should    be able to handle at least 20 elements.

3.  The display of a polynomial should have the general form    illustrated in the following example.

    3.0 X9 - 5.2 X3 + 12.1 X - 7.0  should appear as

    + 3.0 X**9 - 5.2 X**3 + 12. X**1 - 7.0 X**0

   Exponents are 1- or 2-digit integers; coefficients are small real numbers.

4.  Your procedures must make sure that any parameters used are    valid and must display a error message if they are not.
    Copy my program to your disk.  Then, write your UNIT and compile it to disk.  Use the options menu and select the 'Directories' entry.  In the EXE & TPU field, enter the disk and directory where your UNIT was compiled to.  Then, open your copy of my file and compile it to disk.  Finally, run the program.

    When you have everything working, execute the program by performing each command at least once.  Capture the output with Ctrl-PrintScreen or by using redirection.  Hand in a printout of the program and the captured output.


EXTRA CREDIT:

You need NOT implement the ADD command to get full credit for this assignment.  If you do implement the ADD command, it will result in extra credit.

If you implement any of the procedures using recursion, you will be given extra credit.  The more procedures that use recursion, the greater the extra credit assigned.