CS 631 - Computing Fundamentals II - Spring 2005
Programming Assignments


Loyola College > Department of Computer Science > CS 631 > Programming Assignments > Programming Assignment 2

Polynomial Representation with Linked Lists

Due

Tuesday, March 15th at the beginning of class. Email an electronic copy by attaching each .cpp and .h to the email. In addition, turn in a printout of the code. Be sure to include the Honor Code Statement: "I hereby declare that I have abided by the Honor Code during this assignment."

Introduction

The objective of this assignment is a representation of a polynomial using a linked list. This class will support the operations degree, coeffiecient, change coeffiecient, and add as described in the text on pages 160 and 161. In addition, your program should support an evaluate operation which displays the value of the polynomial for some x value entered by the user.

You should provide a menu that allows the user to interact with the program. The user should be able to

The program should prompt the user to enter the necessary information and do error checking and handle incorrect information gracefully.

Assignment

  1. Complete Programming Problem 8 on page 239.
  2. Design your program using a modular approach, which may include classes and/or structs if you wish. You are not allowed to use global variables, although you may define global constants.
  3. Your program should first call a function announce to describe the purpose of your program.
  4. The program will then display the menu and execute the correct operation.

Grading

Partial Solution

This program demonstrates parsing a polynomial. I read the whole line, and then treat the string as an array to find the coefficient and power of each term. This is different from the solution discussed in class which did not handle terms where the power is 0 or terms where the coefficent in 1.