

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Requirements [Lists and Stacks.]
Read from the input stream an (infix) arithmetic expression composed of
A semicolon will be used to denote the end of the expression. Expressions are the same as in the last assignment except operands will only be positive integers (no variables) and thus no assignments (use of =). Translate the expression to an internal code, construct the postfix, print the postfix, evaluate the expression using the postfix, then print the evaluation.
Specifications The input should appear as follows:
Please enter an arithmetic expression 15 * (3 + 2) - 10;
The output should appear as follows:
The expression you entered was 15 * (3 + 2) - 10 The postfix form is 15 3 2 + * 10 - Its evaluation is 65
If the expression does not have balanced parentheses, an error message should be printed, the stack(s) should be made empty, and the program proceed to the next expression. A C + + class must be used to maintain stacks. Appropriate member operators must be provided so the stacks can be manipulated. It is recommended but not required that yet another class be used to maintain lists. The signal to stop and exit will be the empty expression (an expression consisting only of a semi-colon).
Design and Testing Use the following test cases. You may use additional ones.
15 * (3 + 2) - 10; (3 + 2)^2/5; ((3 + 2)^2/5; (3 + 2))^2/5; (120 - 110 / 10 * 10 - 9)^(2*3 - 6);
Error Handling Error checking must at least include assuring the next input symbol is a legitimate token and that the parentheses of the expression are in balance.
Implementation Due Date Friday, 10 November. Submit the following using the project command. Select the correct section of the class, 2050s001. The project id is phw2.