Question: In this programming assignment, you will expand and implement the pseudo code discussed in class for an arithmetic calculator that uses two different stacks. The

In this programming assignment, you will expand and implement the pseudo code discussed in class for an arithmetic calculator that uses two different stacks. The expansion will involve inclusion of more binary operators and the parentheses pairs (possibly nested ones). You will implement your code in Java. Your arithmetic calculators must read lines of text from a text file, where each line contains a syntactically correct arithmetic expression. Your output file must repeat the input line 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 in the following (1 to 6: 1 is the highest and 6 is the lowest. Same precedence operators are evaluated from left to right).

1. Parentheses (possibly nested ones): ( , )

Binary operators:

2. power function: x^y

3. operators: *, / 4. operators: +, - 5. operators: >, , , < 6. operators: ==, !=

As part of this programming assignment, you will do the following:

Implement a Java program. In your program, you will implement and use your own array-

based stack (and not the built-in Java stack) of dynamic size based on the linearly incremental strategy discussed in class (refer to the code segments provided on your slides and the textbook).

c) Briefly explain the time and memory complexity of your calculator. You can write your answer in a separate file and submit it together with the other submissions.

d) Provide test logs for the Java program for at least 20 different and sufficiently complex arithmetic expressions that use all types of operators (including parentheses) in varying combinations.

please provide a full code that works. Please do not copy another answer otherwise I will downvote. Thank you.

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!