Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Mannino Michael

5th Edition

0983332401, 978-0983332404

More Books

Students also viewed these Databases questions

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago