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

Write a program that reads repeatedly from the keyboard a prefix expression, converts it to a fully

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 (make use of the Java Stack class). Assume the 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 prefix expression as shown in the example below. Example: Enter a prefix expression: + 5* 102 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: /* 32-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

Step by Step Solution

3.52 Rating (152 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The simple Java program that reads a prefix expression from the user converts it to a fully parenthesized infix expression and determines its value us... View full answer

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 Programming Questions!