infix to postfix... i need help


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 1 of 1

Thread: infix to postfix... i need help

Threaded View

  1. #1
    Join Date
    Sep 2007
    Posts
    1

    Unhappy 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 05:49 PM.

Similar Threads

  1. java stack infix to postfix
    By xsouldeath in forum Java
    Replies: 1
    Last Post: 12-08-2005, 03:19 AM
  2. Infix to Postfix
    By arvinp in forum Java
    Replies: 0
    Last Post: 03-06-2005, 12:40 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center