We need a calculator that uses Reverse Polish Notation (RPN), just like the great old HP-1xC calculators. Required functions are add (+), subtract (-), multiply (*), divide (/), and raise to the power of (^). You are required to use pointers for Lab 3, NOT C++ arrays or vectors. Your submitted code must compile with no errors in order to receive a grade.

Your submission should include three (3) separate files: RPNCalculator.cpp, RPNCalculator.h (or .hpp) and main.cpp. DON’T forget each file needs a comment header and plenty of line comments to explain your code!

If you collaborate with another student, be sure to give credit by naming the student and explaining what work they did, and what work you did, to complete Lab 3.

For Lab 3, you will create Class RPNCalculator and write an app that uses this class to implement a calculator. Use a display menu/get user input loop that prompts users to enter a number or an operator (+,-,*,/,^). You can, may, should modify the menu code from precious Labs for your RPN Calculator app.

RPNCalculator will implement a stack that holds numbers for a calculation in progress. See p. 286 in Dale 6th Ed. for an example. You are required to use pointers to implement the stack, NOT C++ arrays or vectors.

When the user enters a number, you’ll push it onto the stack. When the user enters an operation, you’ll pop the appropriate numbers (operands) entered, apply the operation to the operands, and report the result.

About RPN: RPN expressions put the operator at the end of the expression, after all the operands, instead of between the operands. Reverse Polish for 1 + 2 looks like this: 12+

RPN for 1 * 2 * 3 is 123*

RPN for (1 * 2 * 3) + 4 is 123*4+

RPN for 1 + 2 * 3 + 4 is 12+3*4+ = 13 (RPN ignores order of operations, so this result is technically wrong. With RPN you have to enter the operands in the right order, like below. But this result (11) is correct on your RPN Calculator.)

RPN for 1 + 2 * 3 + 4 should be 23*1+4+ = 11

RPN for 23 is 23^

If you haven’t used RPN before, watch the short video below. If you have, you know RPN is great for chemistry and physics classes because equations are lots easier to solve (you don’t need parentheses in

Sample Solution

The post RPN Calculator appeared first on nursing writers.

 

“Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!”

 

"Is this question part of your assignment? We Can Help!"

Essay Writing Service