Listing 18.8 using a stack instead of using recursion. **20.23 (Evaluate expression) Modify Listing 20.12, EvaluateExpression.java, to add operators for exponent and % for remainder. For example, 3 ^ 2 is 9 and 3 % 2 is 1. The ^ operator has the highest precedence and the % operator has the same precedence as the * and / operators. Your program should prompt the user to enter an expression. Here is a sample run of the program: Enter an expression: (5 * 2^ 3 + 2 * 3 % 2) * (52 ^ 3 + 2 3 % 2) 4 = 160 Enter

icon
Related questions
Question
←
G
Eval ex X B Final Ex
final re X Q mypro X ✔ MyPro X ℗ Progra X P Pearso X Q(Evalua × b java c= x C My fol X | Qgithub x +
https://plus.pearson.com/products/156673/pages/836?locale=&redirectURL=https://plus.pearson.com/home&lms=Y
A
Chapter 20. Lists, Stacks, Queues, and Priority Queues
Listing 18.8 using a stack instead of using recursion.
(Evaluate expression) Modify Listing 20.12, EvaluateExpression.java, to add
operators ^ for exponent and % for remainder. For example, 3^ 2 is 9 and 3
% 2 is 1. The ^ operator has the highest precedence and the % operator has the
same precedence as the * and / operators. Your program should prompt the
user to enter an expression. Here is a sample run of the program:
**20.23
Enter an expression: (5 2 3 + 23% 2)
(52 ^ 3 + 2 * 3 % 2) * 4 = 160
814
-
Enter
Ⓡ
JH ▾
x
20
O
+
8
Transcribed Image Text:← G Eval ex X B Final Ex final re X Q mypro X ✔ MyPro X ℗ Progra X P Pearso X Q(Evalua × b java c= x C My fol X | Qgithub x + https://plus.pearson.com/products/156673/pages/836?locale=&redirectURL=https://plus.pearson.com/home&lms=Y A Chapter 20. Lists, Stacks, Queues, and Priority Queues Listing 18.8 using a stack instead of using recursion. (Evaluate expression) Modify Listing 20.12, EvaluateExpression.java, to add operators ^ for exponent and % for remainder. For example, 3^ 2 is 9 and 3 % 2 is 1. The ^ operator has the highest precedence and the % operator has the same precedence as the * and / operators. Your program should prompt the user to enter an expression. Here is a sample run of the program: **20.23 Enter an expression: (5 2 3 + 23% 2) (52 ^ 3 + 2 * 3 % 2) * 4 = 160 814 - Enter Ⓡ JH ▾ x 20 O + 8
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer