Question: Write a Python function ArithmeticCalculator that performs the evaluation of an arithmetic expression and outputs the result on screen. Requirements: Your implementation must use ArrayStack

Write a Python function ArithmeticCalculator that performs the evaluation of an arithmetic expression and outputs the result on screen.

Requirements:

Your implementation must use ArrayStack class and follow general guidelines of the algorithm. Your function must be able to evaluate operations +, (both binary and unary forms), *, and / (using integer division).

Your function must be able to evaluate correctly an expression with single-level parentheses.

To test your code you can use several hard-coded arithmetic expressions

Assumptions:

One operation per set of parentheses, for simplicity.

Only addition and subtraction operations could be in parentheses; multiplication and division, having highest priority (in the absence of exponent operation) do not require parentheses, nor will be placed in such.

Dealing with more complex expressions (including the case of nested parentheses) for this assignment.

Dealing with interactive user input (i.e., "prompt the user to provide an arithmetic expression; make sure that it is parsed correctly whether or not the user types the expression with extra whitespace; use a loop to allow for multiple expressions to be evaluated") for this assignment.

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!