Calculator w/ Built in Parser

Project Summary

Created a calculator with a built in parser using data structures. The calculator performed operations such as addition, subtraction, multiplication, division, exponentiation, and factorial! The calculator was also able to handle and evaluate variable expressions. The calculator accepted mathematical expressions in “infix” notation, such as 

    ((10 + 2)*2-8^3)/7

and converts it to its “postfix” equivalent expression

   10 2 + 2 * 8 3 ^ – 7 /

and then evaluate the “postfix” expression.

A stack data structure was used to convert the infix expression to the postfix expression. Once the expression was converted to postfix notation, the expression is evaluated using another stack.

My Role and Experience

This was one of many projects I worked on that utilized basic data structures. I have worked on a few calculators before, but none were advanced like this one. It was interesting to see how data structures are used in the background of something as simple as a calculator, and how helpful they can be for advanced mathematical operations. This project required a lot of different functions, from performing arithmetic operations like addition, to converting the human-readable text to an operation that can be evaluated, to even preserving the order of operations (PEMDAS). It was a great experience to work on project utilizing data structures.