DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 1 of 1

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

Similar Threads

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

Bookmarks

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


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


Sponsored Links