-
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
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|