This assignment is fairly simple in concept, and can be equally as straightforward in design. You must design a menu driven calculator. This calculator will be of the RPN type made popular by Hewlett Packard. In this type of calculator, you enter two numbers and then instruct the computer what type of calculation should be performed on the numbers. For example if you wanted to add 2 and 3, you would enter a 2 and then a 3 and finally you would press the add key.
In this case you will enter one number into the computer, then another number, and finally, you will select the function that you want to perform from a menu. After one calculation is made you should give the user the option of doing an entirely new calculation, performing another calculation using the result of the previous calculation or quitting. That is, for example, you should be able to add two numbers and then add on a third one if you so desire. A sample run might look as follows:
The only part of this that you we have not covered in a previous exercise is how to quit. The return 0; line that we include in the program can actually go anywhere. You should use this line to end your program.
At a minimum you should be able to perform a second calculation or add a third number. As a challenge you can try to see if you can do an unlimited number of calculations before quitting. You do not need to know any commands that we haven't already covered to do this. What you do need to use is something called recursion, a function calling itself. We will cover this later if you don't know what this is.
Your calculator must include addition, subtraction, multiplication and division. As an additional challenge you can add other math functions such as squaring a number.
This program should have comments on almost every line explaining what the program is doing. Additionally, while you may write the program in pairs, each person must explain in their own words how this program works. This explanation should be at least one paragraph and is essentially an English translation of your program. The purpose of this paragraph is to make it clear that you understand the operation of the program.
This program will be graded on the following factors:
This assignment will be due Tuesday, February 24. You must deposit the program in the class folder on the network by this date.