CSE 3302 Programming Assignment 02 – RPN Calculator using Python solved

$25.00

Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (5 votes)
Use Python to create a simple calculator that accepts Reverse Polish Notation (RPN) and displays the final answer (Intermediate steps or results need not be displayed). It only accepts 4 operators +, -, *, /. You should convert the algebraic notation to RPN before using it as input to your program. The input will be provided in a text file called input_RPN.txt. There will be one RPN expression in each line. Your code should be able to read in the file and print the result for each RPN in a new line.
Example of RPN: – If you want to compute the answer for the algebraic notation 4 + 2 , your RPN will be 4 2 + and your output should be 6. This is a simple expression. More complex algebraic notations will be used to test your program like the one below.
Example algebraic notation: ( 4 + 2 * 5 ) / ( 1 + 3 * 2 )
Translated into RPN: 4 2 5 * + 1 3 2 * + /

Extra credit
Your code will take in an algebraic expression and convert it to RPN and evaluate the RPN. Print the RPN and the result in separate lines. If you are implementing extra credit, your file should be name as netid_EC.py. The input file name will be input_RPN_EC.txt and it will have algebraic expressions.

Note: – Your code should be able to read the input file from the same folder (which has your .py file). Do not hard code the path to the file in your laptop/desktop. Use os to get the path and read the input file.