# c-programming-Programming-2-RPN-Calculator-

Programming 2â€“ RPN Calculator â€“

Infix to Postfix Conversion and The Evaluations of the Postfix Expression.

### Save your time - order a paper!

Get your paper written from scratch within the tight deadline. Our service is a reliable solution to all your troubles. Place an order on any task and we will take care of it. You won’t have to worry about the quality and deadlines

Order Paper Now

You are to design and implement and algorithm in Java, to input an Infix expression , convert to a postfix expression and finally evaluate the postfix expression Problem description:

1.We are used to infix notation – â€3 + 4â€ – where the operator is between the operands. There is also prefix notation, where the operand comes before the operands. A Reverse Polish Notation calculator uses postfix notation, and was one of the first handheld calculators built. At first, it seems confusing, but is very logical once you think about it. Instead of doing â€2 + 3 + 4â€, you may do â€2 [enter] 3 [enter] 4 [enter] + +â€.

2.You will be implementing a conversion from infix to RPN and then perform an RPN calculator for this assignment.

3.How does an RPN calculator work? It is quite simple in principle. The calculator keeps a stack – a list of numbers. When you type a number and hit â€enterâ€, it pushes, or appends the number to the stack. So you build up a stack of numbers. Whenever you click an operand, it applies the operator to the top of the stack. In the previous example, it builds a stack like [2, 3, 4]. When you hit the first â€+â€, it pops off the top/most recent two elements off the list and â€plusesâ€ them. Lastly, it pushes the result back on the stack, so it looks like [2, 7]. When you hit plus again, it pops off the two elements (so the stack is temporarily empty), adds them, and pushes it back on the stack, so you get [9] .

3 What you need to do

For the first part of this assignment, think about what classes you need. Java has a Stack class for you, but write your own (do not use the Java Stack class). Use encapsulation, think about what methods it should have, and call it something like CalculatorStack. Add an option toâ€ rollâ€ the stack; shift it left or right by one (and the end number rollls) to the other end). Other classes may include Controller, Handler, or SpecialOperationsHandler.

4 Why?

â€¢ Itâ€™s one of the better assignments I can think of as a teaching tool

â€¢ RPN calculators are awesome – theyâ€™re far more logical than infix calculators once you get used to them

â€¢ You should learn RPN calculators; besides the historical importance, it forces you to think differently. Several example done during class lectures.

The following code below is a sample on how to evaluate the RPN expression â€¦