subject

Convert infix to postfix

(Convert infix to postfix)

Note:

Postfix notation is a way of writing expression without using parentheses. For example, the expression ( 11 + 12 ) * 13 would be written as 11 12 + 13 *

Assume that ALWAYS there is a space between operands and operators in the input expression.

Use two stacks, one to store the operands and one to store the operators.

Your program only accpets following operators :

( )

+

-

/

*

Write a method to converts an infix expression into a postfix expression using the following method:

String infixToPostfix(String expression)

For example, the method should convert the infix expression

( 13 + 25 ) * 34 to 13 25 + 34 *

and

20 * ( 10 + 30 ) to 20 10 30 + *.



import java. util.*;
import java. lang.*;
import java. io.*;

class InfixToPostfix{
public String infixToPostfix(String expression) {

}
}
class DriverMain{
public static void main(String args[]){
Scanner input = new Scanner(System. in);
InfixToPostfix postfix = new InfixToPostfix();
try {
System. out. println(postfix. infixToPostfix(input. nextLine()));
}
catch (Exception ex) {
System. out. println("Wrong expression");
}
}
}

only make change to class infixToPostfix

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 04:30
Which of the statements below is true? the formatting, standard, and drawing commands are unavailable. the formatting, standard, and drawing commands have been used. the formatting, standard, and drawing toolbars are displayed. the formatting, standard, and drawing toolbars are hidden.
Answers: 1
question
Computers and Technology, 22.06.2019 19:20
Terri needs to insert a cover page into her document. where should she go to access the commands to do so? o insert tab, objects group o insert tab, illustrations group o insert tab, pages group o insert tab, media group submit
Answers: 1
question
Computers and Technology, 23.06.2019 21:00
Alcohol’s affects on the cornea and lens of the eye make it more difficult
Answers: 1
question
Computers and Technology, 23.06.2019 23:30
A. in packet tracer, only the server-pt device can act as a server. desktop or laptop pcs cannot act as a server. based on your studies so far, explain the client-server model.
Answers: 2
You know the right answer?
Convert infix to postfix

(Convert infix to postfix)

Note:

Pos...
Questions
question
Mathematics, 24.05.2021 06:00
question
Mathematics, 24.05.2021 06:00
Questions on the website: 13722362