-
infix to postfix... i need help
i cant get the output in post fix some one please help...heres my code
import java.util.Scanner;
import java.io.*;
import java.util.*;
public class Infix{
public static void main( String[] args){
Scanner scan=new Scanner(System.in);
Stack<String> stack = new Stack<String>();
System.out.println(" enter infix");
String s=scan.next();
while (!s.equals(0)){
String postfix="";
if ( s.equals("+")) stack.push(s);
else if ( s.equals("-")) stack.push(s);
else if ( s.equals("*")) stack.push(s);
else if ( s.equals("/")) stack.push(s);
else if ( s.equals("(")) System.out.print("");
else if ( s.equals(")")) System.out.print(stack.pop()+"");
System.out.println("postfix");
System.out.print(s);// I DONT KNOW HOW TO ADD ALL THE VARIABLES INTO A SEPERATE STRING
System.exit(1);
}
}
}
Last edited by boygenius_08; 09-17-2007 at 04:49 PM.
Similar Threads
-
By xsouldeath in forum Java
Replies: 1
Last Post: 12-08-2005, 02:19 AM
-
Replies: 0
Last Post: 03-05-2005, 11:40 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks