Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In this programming assignment, you will expand the pseudo code discussed in class for an arithmetic calculator that uses two different stacks, then implement the
In this programming assignment, you will expand the pseudo code discussed in class for an arithmetic
calculator that uses two different stacks, then implement the Java solution of the algorithm. However,
we first need to start by creating the stacks, as you are NOT allowed to use any builtin types from the
language. Doing so will void your assignment.
I Implement your stack using expandable arrays. Since the length of the expression is
unknown ahead of time, your stack will expand as needed. You should however keep two
important points in mind while implementing your stacks:
a Amortized time complexity for adding any element to the stacks cannot be more than
O; and
b Space complexity can NOT be more than the exact number of items that you finally
pushed into the stack ie exactly On for n elements
II Now, as your stacks are ready, you can continue with the problem itself, where you need
to use your stacks to calculate the value of a given mathematical expression. The expression
will include particular set of binary operators see below as well as parentheses pairs
possibly nested ones
In particular, your arithmetic calculators must read lines of text from a text file, where each
line contains a syntactically correct arithmetic expression. Your output will be directed to
a file, where you will record the input line the expression and print the computed result
on the next line.
Your calculators must support the following operators on integers and observe the standard
operator precedence as shown below to where is the highest and is the lowest.
Same precedence operators are evaluated from left to right
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