Question: In this lab you will be creating a prefix calculator. The user will enter an expression in prefix form and your program will calculate and

In this lab you will be creating a prefix calculator. The user will enter an expression in prefix form and your program will calculate and display results. An expression in prefix form states the operation to be performed before the operands. For example the prefix expression: +23 means that the operation to be performed is addition, the operands are 2 and 3. Therefore, the result of the calculation will be 5. Prefix notation is widely used in functional programming languages. Some additional expressions and their equivalent in traditional infix form (with operator in the middle are shown below.)
Prefix Form
Infix Form
Result
20-30
20+(-30)
-10
24
2*4
8
74
7-4
3
/227
22/7
3
/210
21/0
NaN
All operations are integer operations for this Lab. Note the division operation in particular. In addition to the operations listed above, you will also support abs operation which will compute the absolute value of the given number. The following examples show how the calculator will run. You can break the user input by using the split function to separate the operands and operators from the input string. You must detect possible division and report it.In this lab you will be creating a prefix calculator. The user will enter an expression in prefix form and your program will calculate and display results. An expression in prefix form states the operation to be performed before the operands. For example the prefix expression: +23 means that the operation to be performed is addition, the operands are 2 and 3. Therefore, the result of the calculation will be 5. Prefix notation is widely used in functional programming languages. Some additional expressions and their equivalent in traditional infix form (with operator in the middle are shown below.)
\table[[Prefix Form,Infix Form,Result],[+20-30,20+(-30),-10],[***24,2**4,8],[-74,7-4,3],[?227,227,3]]
All operations are integer operations for this Lab. Note the division operation in particular. In addition to the operations listed above, you will also support abs operation which will compute the absolute value of the given number. The following examples show how the calculator will run. You can break the user input by using the split function to separate the operands and operators from the input string. You must detect possible division and report it.
 In this lab you will be creating a prefix calculator. The

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!