String converting to Stack/ Parsing

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • eyeore
    New Member
    • Oct 2009
    • 1

    String converting to Stack/ Parsing

    Hello everyone my String reverse code works but my professor wants me to use pop top push or Stack code and parsing code could you please teach me how to make this code work with pop top push or Stack code and parsing code my professor i does not like me using buffer reader on my code and my professor did even give me an example code for parsing as well as pop push top or Stack code and i don't know how to do this code into parsing and pop push top code i been looking all through the bookstore and yet no avail i did see any book about parsing code as well as pop top push code please you teach me please
    Code:
    [import java.io.*;
         import java.util.*;
    
         class Reverse{
    
               String reverse(String str) {
                   String rStr = new StringBuffer(str).reverse().toString();
                   return rStr;
               }
    
    
               String alphaOrder(String str){
                   char[] charArray = str.toCharArray();
                   Arrays.sort(charArray);
                   String aString = new String(charArray);
                    return aString;
               }
    
               public static void main(String[] args) throws IOException {
                  System.out.print("Enter the String : ");
                 BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
                  String inputString = br.readLine();
                  System.out.println("String before reverse : " + inputString);
                  Reverse  obj = new Reverse();
                  String reverseString = obj.reverse(inputString);
                  String alphaString = obj.alphaOrder(inputString);
                  System.out.println("String after reverse : " + reverseString);
               }
          }
    Last edited by Frinavale; Jan 13 '10, 03:39 PM. Reason: Please post code in [code] ... [/code] tags. Added code tags.
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Do you know what a Stack is?

    If I were you I would start by researching what a Stack data structure is. For example a quick google search came up with this wiki article on what a Stack data structure is all about.

    Once you understand what a Stack is...consider how you could use it to solve your problem. (Hint: you are going to need to "parse" or "break up" the text into chunks to accomplish your task).

    After you understand what a Stack data structure is and have a good idea of how to use it to solve your problem.... I recommend that you go to the Java API and see if there is already a Stack class developed to save yourself time in creating one.



    -Frinny

    Comment

    Working...