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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 20:00, ksanchez2100
Need asap assignment directions: think of an organization (business, religious institution, volunteer organization, sports team) with which you have been involved. imagine outfitting it with an it infrastructure. prepare a plan for what you would do to support outfitting it. draw a map of a network connecting all the individuals, give them pcs and printers, and lay out the design as best you can. the purpose is to begin working with these concepts, not to build a perfect network.
Answers: 2
image
Computers and Technology, 23.06.2019 02:30, paolaviviana
Experimental data that is expressed using numbers is said to be
Answers: 1
image
Computers and Technology, 23.06.2019 10:00, karissanichole18
Install and use wireshark program ( send back screen shots and other vital information) case project 3-2: decode a tcp segment in a wireshark capture in this chapter, you walked through tcp segment to interpret the data included in its header. in this project, you use wireshark to capture your own http messafes, examine the tcp headers, and practice interpreting the data you'll find there. 1. open wireshark and snap the window to one side of your screen. open a browser and snap that window to the other side of your screen so you can see both windows.
Answers: 2
image
Computers and Technology, 23.06.2019 14:30, qveenvslayin
The basic work area of the computer is it screen that you when you first fire up your computer
Answers: 1
You know the right answer?
Convert infix to postfix

(Convert infix to postfix)

Note:

Pos...

Questions in other subjects:

Konu
Geography, 25.09.2020 04:01
Konu
Mathematics, 25.09.2020 04:01
Konu
Mathematics, 25.09.2020 04:01