Question: Q4. In this programming assignment, you will first design using pseudo code two versions of arithmetic calculators. The first version will be based on the

 Q4. In this programming assignment, you will first design using pseudocode two versions of arithmetic calculators. The first version will be based

Q4. In this programming assignment, you will first design using pseudo code two versions of arithmetic calculators. The first version will be based on the pseudo code discussed in class that uses two different stacks. The second version must be completely based on recursion and must not use any stack (however, we know by now that recursion will implicitly use JVM's own stack as in regular function calls). You will implement the first version in Java. Your arithmetic calculators must read lines of text from a text file, where each line contains a syntactically correct arithmetic COMP 352-Winter 2019 Assignment 2 - page 1 of 2 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 8: 1 is highest and 8 is lowest. Same precedence operators are evaluated from left to right) 1. Parentheses (possibly nested ones): (,) Un 2. factorial:! minuS. function. 4. power 5. operators: *,/ 6. operators: +, - 7. operators: >, 2, S, 8. operators. As part of this programming assignment, you will do the following: a) b) Implement a Java program for the first version. In your program, you will implement and Design and submit the pseudo-code for both the versions of arithmetic calculator use your own array-based stack (and not the built-in Java stack) of variable size based on the doubling 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 both versions of your calculator. You carn write your answer in a separate file and submit it together with the other submissions. d) Provide test logs for the first version for at least 20 different and sufficiently complex arithmetic expressions that use all types of operators (including parentheses) in varying Two stacks: opStk holds operators Algorithm EvalExpo Input: a stream of tokens representing an rithmetic expression (with numbers) Use S to hold a special "end of input token with lowest precedence Output: the value of the expression Algorithm doOp 0 while there's another token z x valsik.popo; if isNumber(z) then valStk.push(z) op | prec(refOp)S prec(opStk.top0) repeatOps(S); return valStk.topO doop(

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!