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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started