Show Bid Request
infix to postfix converter help
Bid Request Id: 11388
|
|
|
Description:
Given the following modules of java code:
InfixToPostfixClient.java InfixToPostfixConverter.java Symbol.java LinkedStackPT.java StackPt.java
With the exception of InfixToPostfixConverter.java, all modules are complete and will compile. InfixToPostfixConverter.java is partially complete. Your assignment is to complete the methods, processOperator and popRest using Object Oriented Programming techniques.
The program must compile and work properly when finished.
Deliverables: import java.util.StringTokenizer;
public class InfixToPostfixConverter {
private StackPT opStack; // operator stack for conversion private StringTokenizer str; // the character stream private String postfixExpression; // postfix string to be built and returned. public InfixToPostfixConverter( String s ) { str = new StringTokenizer( s ," "); // Instantiate a StringTokenizer Object. postfixExpression = ""; // Initialize the postfix string. opStack = new LinkedStackPT( ); // Instantiate the Stack. opStack.push( new Symbol('_')); // Initialize the Stack. }
public String getValue( ) { Symbol currentSym;
while (str.hasMoreTokens()) { char inputCh = str.nextToken().charAt(0); //Get the next char of input. currentSym = new Symbol(inputCh); //Encapsulate it in a Symbol Object. if (currentSym.isOperator()) processOperator(currentSym); //Process the operator. else postfixExpression += currentSym.getChar(); //Append to the output String. } popRest(); //Process remaining operators on the stack. return postfixExpression; }// end getValue
private void processOperator(Symbol inputSymbol ) { Symbol stackToken;
if (inputCh = ")") // if the input symbol is a closed parenthesis, pop & append until '(' { // pop a Symbol from the stack. A cast must be used before storing into a Symbol type. // As long as the symbol just popped is not an open parenthesis { // extract the encapsulated char from the Symbol // append the char to the postfix String. // pop the next Symbol from the Stack as above. } } else // pop & append all operators on stack of greater precedence than input operator. { // Get the input precedence of the input Symbol // Get the top of stack precedence of the top-of-stack Symbol //As long as the input precedence is less than or equal to the top of stack precedence { // pop a Symbol from the stack. (casting is necessary as above.) // extract the char encapsulated in the Symbol // append to the postfix String. // Get the input precedence of the input Symbol // Get the top of stack precedence of the input Symbol } // push the input Symbol onto the stack. } }// end processOperator method
private void popRest() {
// pop a symbol from the stack. // as long as the symbol is not the end-of-input symbol { //extract the char value encapsulated in the symbol. // append it to the postfix Sring // pop the next symbol from the stack } } }//end class
Platform:
It needs to be able to run in DOS for Windows 95+
Must be 100% finished and received by buyer on:
Mar 22, 2002 EDT
Deadline legal notes: All times are expressed in the time zone of the site EDT (UT - 5). If the buyer omitted a time, then the deadline is 11:59:59 PM EDT on the indicated date.
Additional Files:
This bid request includes IMPORTANT additional attached files. Please download and read fully before bidding.
Remember that contacting the other party outside of the site (by email, phone, etc.) on all business projects < $500 (before the buyer's money is escrowed) is a violation of both the software buyer and seller agreements.
We monitor all site activity for such violations and can instantly expel transgressers on the spot, so we thank you in advance for your cooperation.
If you notice a violation please help out the site and report it. Thanks for your help.
|
|
Bidding/Comments:
|
All monetary amounts on the site are in United States dollars.
Rent a Coder is a closed auction, so coders can only see their own bids and comments. Buyers can view every posting made on their bid requests. |
See all rejected bids (and all comments)
Name |
Bid Amount |
Date |
Coder Rating |
|
|
This bid was accepted by the buyer!
|
$15 (USD)
|
Mar 21, 2002 1:17:15 AM EDT
|
8.35
(Very Good)
|
|
|
Easy, made by your dEADLINE |
|
|
|
|
|