CptS 122 – Data
Structures
Programming Assignment 4: Evaluation of Infix
Expressions Using Stacks
Assigned:
Due:
I. Learner
Objectives:
At the conclusion of
this programming assignment, participants should be able to:
II.
Prerequisites:
Before starting
this programming assignment, participants should be able to:
Write a program to
evaluate infix expressions. An infix expression looks like the following:
9 * (5 - 4) + 2 / 6
This program must
first convert the infix expression to a postfix expression, and then evaluate
the postfix expression. A postfix expression for the above infix expression
looks like the following:
9 5 4 - * 2 6 / +
For this assignment
you will need to implement and apply one stack to convert from infix to
postfix, and implement and apply a second stack to evaluate the postfix
expression. Your program must take the infix expression as a string from the user.
Please complete
exercises 12.12 and 12.13 form your Deitel & Deitel C How to Program
textbook. These exercises provide you with the algorithms required to perform
the correct conversions and evaluations. Create a single program only, which
combines both exercises. Also, be sure to allow the user to continue to enter
infix expressions until they want to quit the program.
BONUS:
Provide appropriate
test cases and drivers for each function in your stack application to receive
up to 10 bonus points. For an additional 10 points allow for your program to
accept multi-digit operands and unary sign operators (+ and -).
IV. Submitting Assignments:
V. Grading Guidelines:
This assignment is
worth 120 points. Your assignment will be evaluated based on a successful
compilation and adherence to the program requirements. We will grade according
to the following criteria: