1. Engineering
  2. Computer Science
  3. i want to write this code using this template create...

Question: i want to write this code using this template create...

Question details

I want to write this code

Write a Java program that prompts for.and reads a postfix expression. It then uses the above algorithm to evaluate and print the value of the postfix expression. Sample input/ output: 6 2+5 8 4/ 6 25 * 8 4 - value 58 24 38

using this template

Create an empty stack

Read postfix expression as a string ;

while(there are more tokens in the string){

     if(current token is an operand)

        push token in the stack;

     else if(current token is an operator oprt ){

         operand1 = pop stack;

         operand2 = pop stack;

         result = operand2 oprt operand1;

         push result in the stack;

      }

}

pop result from the stack and print it;

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution