Question: Computer Science 1 : Java Programming Dr. David Cline Program: Postfix Calculator In this program, you will write a command line calculator that can evaluate







Computer Science 1 : Java Programming Dr. David Cline Program: Postfix Calculator In this program, you will write a command line calculator that can evaluate simple mathematical expressions on typed in postfix notation (also called reverse polish notation, or RPN), as well as store variables for later use in other expressions Postfix notation: In a typical mathematical expression that you are probably used to, such as 5+ 2, the operator(+) goes in-between the two operands (5 and 2). This is called "infix" notation. Postfix notation places the two operands first, and the + sign last, giving 5 2 +. One of the main benefits of postfix notation is that it is easy to evaluate using a stack. Parentheses are not needed, nor are precedence rules, since there is only one reasonable way to evaluate the expression. The algorithm to do this uses a stack of numbers, and can be stated in a few steps as follows: Given a Postfix expression such as "2 3 + x-break it into tokens, and initialize an empty stack of numbers. Then do the following steps
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
