$24
Read carefully:
• The project has two parts. The second part is an extension of the first. You only need to submit one copy of your code.
• Download the rpn.h and rpn.cpp files for the started code.
• You must submit the source files and a README.txt file in a zipped folder.
• You should not use existing source code as a primer that is currently available on the Internet. You must specify in your documentation any sources of code that you have viewed to help you complete this project. Excessive collaboration, or failure to list external code sources will result in the matter being referred to Student Judicial Affairs.
• You must specify in your README file on how to compile and run your code.
Part 1
Write a C++ program called rpn to implement a reverse polish notation calculator.
• For more information on the notation see: https://en.wikipedia.org/wiki/Reverse_Polish_ notation.
• Your implementation may use C++ 2011 standard, and any of the STL containers.
• The input is represented an array of strings, each of which is either an operator or an operand.
• The returned result is a double precision floating number.
• The following operationss must be implemented: add (+), subtract ( ), multiply ( ), divide (/), exponentiation ( ), floor (<) and ceiling (>).
• The program must catch any exceptions and display the appropriate error message.
• Use standard input and output for this program.
Example:
• Input: [”2”, ”12”, ”6”, ” ”, ”/”, ”5”, ”3”, ” + ”, ” ”] (an array of strings)
• Output: 2.6667 (or 83 )
1
Part 2
Modify the rpn program from the first part to allow for an optional output. The "-l" option will display a listing of the input values in the following format: (operator operand1 operand2). Each operand should be indented one level greater than its operator, and trailing parens should be at the equivalent level of indentation to its match.
Example: The output of the example input in Part 1 with the -l opetion should be:
• (*
• (/
• ( -
• 12
• 6
• )
• 2
• )
• (+
10 5
11 3
12 )
13 )
2