Starting from:
$35

$29

Reverse Polish Notation Calculator Solution

Implement the RPN calculator pseudo-code supplied in the lecture as real code. Your program must:




 
Prompt the user for an infix math problem.




 
Convert the problem to postfix.




 
Output the problem in postfix.




 
Calculate the result.




 
Display the result.




 
Ask the user for another math problem.




If the user enters quit for the problem, end the program.




Use the standard stack and queue class/methodology provided by your preferred language's framework, such as the STL stack/queue classes in C++ or the Array class in JavaScript. Put the conversion procedure in its own function. Put the calculate result procedure in its own function as well.




You need to handle multi-digit numbers even though the sample code does not. In your version, numbers (operands) are separated from operators by zero or more spaces, while numbers are separated from other numbers by one or more spaces. While negative numbers cannot be input by the user, the result may be negative based on the input math problem.




You must support +, -, *, /, and % operators, as well as (potentially nested) parenthesis. For +10 extra credit, also support raising a number to a power with the POW operator, which must appear as those three letters in all uppercase.







Note: You must not submit your "node_modules" folder if you are working on NodeJs/JavaScript. (Just submit your JavaScript source code and package.json file)










RPN Calculator





































1 of 5 , 7:35 PM
Reverse Polish Notation Calculator https://sit.instructure.com/courses/23566/assign...







Criteria
Ratings
Pts








Prompt user for infix expression. Intuitively, expression will be entered in a single
5.0 pts
0.0 pts


line: -3 points if program does not accept single-line expressions.
Full
No
5.0 pts
Marks
Marks












Infix - postfix conversion. Resulting postfix expression must be logged to
15.0 pts
0.0 pts


console.
Full
No
15.0 pts
Marks
Marks












Evaluate and display the result of postfix expression. Verify that result is
15.0 pts
0.0 pts


generated by postfix evaluation, and NOT infix evaluation.
Full
No
15.0 pts
Marks
Marks












Use of apt data structures - infix queue, postfix queue, operator stack (STL
5.0 pts
0.0 pts


queue/stack usage is allowed)
Full
No
5.0 pts
Marks
Marks












Program loops till user enters "quit" - Keep prompting user for and evaluating
5.0 pts
0.0 pts


multiple expressions until user decides to quit.
Full
No
5.0 pts
Marks
Marks












Support the input infix expression domain: non-negative numbers. -2 points if
5.0 pts
0.0 pts


decimal numbers not supported.
Full
No
5.0 pts


Marks
Marks












Support the output result domain: real numbers. Output may be a fraction. It may
5.0 pts
0.0 pts


also be negative. (Output may be rounded to 2 digits or more. -4 points if output
Full
No
5.0 pts
is rounded to whole numbers)
Marks
Marks
















Support for operators {+, -, *, /, %} and parentheses (2 points per operator and 5
15.0 pts
0.0 pts


points for parentheses).
Full
No
15.0 pts
Marks
Marks












Evaluation follows BODMAS operator precedence (15 points for precedence
15.0 pts
0.0 pts


logic).
Full
No
15.0 pts
Marks
Marks












[ (+bonus points+)] Support for POW operator
10.0 pts
0.0 pts




Full
No
10.0 pts


Marks
Marks












Handle spaces in input infix expression by ignoring them.
3.0 pts
0.0 pts




Full
No
3.0 pts


Marks
Marks





















2 of 5 , 7:35 PM
Reverse Polish Notation Calculator https://sit.instructure.com/courses/23566/assign...










Criteria
Ratings
Pts








Output postfix expression must be readable: operands and operators separated
3.0 pts
0.0 pts


by 0 or more spaces, operands and operands separated by 1 or more spaces.
Full
No
3.0 pts


Marks
Marks












Error catching: Catch divide-by-zero exception, NaN exception. (Input infix
4.0 pts
0.0 pts


expression can be assumed to be valid)
Full
No
4.0 pts
Marks
Marks












Miscellaneous Test Cases and Coding Style
5.0 pts
0.0 pts




Full
No
5.0 pts


Marks
Marks












Note: 30 points penalty for late submission!
0.0 pts
0.0 pts




Full
No
0.0 pts


Marks
Marks















Total Points: 110.0



























































































































3 of 5 , 7:35 PM

More products