Write a program that reads repeatedly from the keyboard a prefix expression, converts it to a fully parenthesized infix expression, and determines the value of the expression. Your program must use a stack. Assume each entered prefix expression contains only integer numbers and the *, /, +, - operators. After reading and processing a prefix expression, your program should ask the user if he/she wants to enter another expression as shown in the example below. Example: Enter a prefix expression: + 5 * 10 2 The corresponding infix expression is: (5 + (10 * 2)) and its value is 25 Do you want to enter another expression (Y/N)? Y Enter a prefix expression: / * 3 2 -74 The corresponding infix expression is: ((3 * 2)(7 - 4)) and its value is 2 Do you want to enter another expression (Y/N)? N

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter18: Stacks And Queues
Section: Chapter Questions
Problem 9PE
icon
Related questions
Question
Write a program that reads repeatedly from the keyboard a prefix expression, converts
it to a fully parenthesized infix expression, and determines the value of the expression. Your
program must use a stack. Assume each entered prefix expression contains only integer numbers
and the *, /, +, - operators. After reading and processing a prefix expression, your program should
ask the user if he/she wants to enter another expression as shown in the example below.
Example:
Enter a prefix expression: + 5 * 10 2
The corresponding infix expression is: (5 + (10 * 2)) and its value is 25
Do you want to enter another expression (Y/N)? Y
Enter a prefix expression: / * 3 2 - 74
The corresponding infix expression is: ((3 * 2)(7 - 4)) and its value is 2
Do you want to enter another expression (Y/N)? N
Transcribed Image Text:Write a program that reads repeatedly from the keyboard a prefix expression, converts it to a fully parenthesized infix expression, and determines the value of the expression. Your program must use a stack. Assume each entered prefix expression contains only integer numbers and the *, /, +, - operators. After reading and processing a prefix expression, your program should ask the user if he/she wants to enter another expression as shown in the example below. Example: Enter a prefix expression: + 5 * 10 2 The corresponding infix expression is: (5 + (10 * 2)) and its value is 25 Do you want to enter another expression (Y/N)? Y Enter a prefix expression: / * 3 2 - 74 The corresponding infix expression is: ((3 * 2)(7 - 4)) and its value is 2 Do you want to enter another expression (Y/N)? N
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Stack
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning