Infix to Postfix expression Java Program

Availability: In stock

Regular Price: $15.00

Special Price: $12.00

OR

Infix to Postfix expression Java Program

Double click on above image to view full picture

Zoom Out
Zoom In

More Views

Quick Overview

Infix to Postfix expression Java Program


Write a java program that converts an infix expression into an equivalent postfix expression.


The rules to covert an infix expression to postfix expression are:
Scan the expression from left to right in only one pass.
If the next symbol is an operand, append it to the postfix expression.
If the next symbol is a ‘(‘, push it onto the stack.
If the next symbol is a ‘)’, pop and append all the symbols from the stack until the first ‘(‘ is found. Discard the ‘(‘
If the next symbol is an operator:


a. Pop and append to the postfix expression every operator from the stack that is above the most recently scanned ‘(‘ and that has precedence greater than or equal to the new operator.


b. Push the new operator onto the stack.
After the infix expression is completely processed, pop and append to the postfix string everything from the stack.


In this program, you are to consider the following arithmetic operators: +, -, * and /. You may assume that the expressions you process are error free.
Please check your program using the following:
1. A + B – C
2. (A + B) / (C – D)
3. A + ( (B + C) * ( E – F ) – G ) / (H – I )
Hand in a hard copy of your source code. You may append your testing as part of your documentation.

Regular Price: $15.00

Special Price: $12.00

Details

Infix to Postfix expression Java Program

Write a java program that converts an infix expression into an equivalent postfix expression.

The rules to covert an infix expression to postfix expression are:
Scan the expression from left to right in only one pass.
If the next symbol is an operand, append it to the postfix expression.
If the next symbol is a ‘(‘, push it onto the stack.
If the next symbol is a ‘)’, pop and append all the symbols from the stack until the first ‘(‘ is found. Discard the ‘(‘
If the next symbol is an operator:

a. Pop and append to the postfix expression every operator from the stack that is above the most recently scanned ‘(‘ and that has precedence greater than or equal to the new operator.

b. Push the new operator onto the stack.
After the infix expression is completely processed, pop and append to the postfix string everything from the stack.

In this program, you are to consider the following arithmetic operators: +, -, * and /. You may assume that the expressions you process are error free.
Please check your program using the following:
1. A + B – C
2. (A + B) / (C – D)
3. A + ( (B + C) * ( E – F ) – G ) / (H – I )
Hand in a hard copy of your source code. You may append your testing as part of your documentation.

Product Tags

Use spaces to separate tags. Use single quotes (') for phrases.