CS 153 Data Structures I

Assignment #8

Due: 3/8/01

Purposes:

  1. Create a CStack class derived from the generalized CBag
  2. Create a ...Dlg member function that converts an infix expression to postfix
  3. Create a ...Dlg member function can evaluate an integer postfix expression

The algorithms for performing #2 and #3 are in your text on pages 367 and 370.

The user interface (GUI)

  1. a CString edit box labeled InFix Expression
  2. a CString edit box labeled PostFix Expression
  3. an int edit box labeled Result
  4. a Button label 'Convert InFix to PostFix'
  5. a Button label 'Evaluate PostFix' 

Sample:


Infix = 3 + 4 * 5
Postfix = 3 4 5 * +
Answer = 23

Hints:

You may enter your expression with blanks surrounding each token.
Using the function strtok() will be of great assistance.
Don't convert ASCII numbers to ints until actually doing arithmetic
You may use 2 CStacks (1 of type CString and 1 of type int)