## Lab 4

### Purpose

To become familiarized with the use of stacks as data structures.

### Key Reading

- 5.1-5.4

### Background

Develop an Expression Manager that performs several operations on infix and postfix expressions. Be able to convert from one form to the other, evaluate postfix expressions, and check for balanced parenthetical expressions.

You may also refer to Edsger Dijkstra's "Shunting-yard algorithm" for additional help, which can be viewed here.

### Requirements

You will need these files to complete the assignment. Details for method constraints are found in these documents and are still a part of the requirements. (If downloaded before 9/17, 2:00 pm re-download. There are errors that were fixed that will cause the driver to break on working code.)

Extend the `ExpressionManagerInterface.h`.

#### Part 1 - Balanced Symbols Check (10 points)

- Determine and report whether an expression is balanced. { [ } ] is not balanced. [ ( ) ] is balanced and valid

#### Part 2 - Infix to Postfix Conversion (10 points)

- Alert the user if the given infix expression is not valid
- Convert the infix expression into a postfix expression and display the postfix expression

#### Part 3 - Postfix to Infix Conversion (10 points)

- Alert the user if the given postfix expression is not valid
- Convert the postfix expression into an infix expression and display the infix expression

#### Part 4 - Postfix Expression Evaluation (10 points)

- Alert the user if the given postfix expression is not valid
- Evaluate the given postfix expression and display the result
- Handle attempts to divide by 0

### Requirement Notes

#### General

- Valid expressions consist of integers; brackets, braces, and parentheses; and +, -, *, /, and %. Reject any invalid expressions and inform the user.
- Your calculations should perform integer divison and produce integer results
- Valid expressions also need to satisfy standard infix or postfix requirements
- {,},(,),[, and ] are the only symbols considered for the Balanced Symbols Check
- Your program should allow the user to repeat the activities
- You can assume there will be a space between every number or operator
- You must put parenthesis '()' around every part of the expression during the postfix to infix conversion. i.e. "4 2 5 + *" = "( 4 *( 2 + 5 ) )"
- You must use the stack class pre-defined in the C++ Standard Template Library (STL). i.e. `#include <stack>`

#### Test Cases

- The expressions in the test files will be written with one complete expression on each line. Available below are small test files you may use to test your program for pass off on each part. This is not a comprehensive set of tests, but it should familiarize you with the format and give you ideas for additional test cases you can add. Your program must display the result of the selected operation for each of the expressions in the file.
  - Part1.txt
  - Part2.txt
  - Part3.txt
  - Part4.txt