473,402 Members | 2,055 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

String converting to Stack/ Parsing

1
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
Expand|Select|Wrap|Line Numbers
  1. [import java.io.*;
  2.      import java.util.*;
  3.  
  4.      class Reverse{
  5.  
  6.            String reverse(String str) {
  7.                String rStr = new StringBuffer(str).reverse().toString();
  8.                return rStr;
  9.            }
  10.  
  11.  
  12.            String alphaOrder(String str){
  13.                char[] charArray = str.toCharArray();
  14.                Arrays.sort(charArray);
  15.                String aString = new String(charArray);
  16.                 return aString;
  17.            }
  18.  
  19.            public static void main(String[] args) throws IOException {
  20.               System.out.print("Enter the String : ");
  21.              BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
  22.               String inputString = br.readLine();
  23.               System.out.println("String before reverse : " + inputString);
  24.               Reverse  obj = new Reverse();
  25.               String reverseString = obj.reverse(inputString);
  26.               String alphaString = obj.alphaOrder(inputString);
  27.               System.out.println("String after reverse : " + reverseString);
  28.            }
  29.       }
Jan 10 '10 #1
1 4340
Frinavale
9,735 Expert Mod 8TB
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
Jan 13 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: Freddie | last post by:
Happy new year! Since I have run out of alcohol, I'll ask a question that I haven't really worked out an answer for yet. Is there an elegant way to turn something like: > moo cow "farmer john"...
2
by: Jonas Prismesen | last post by:
Hi! I have string like this: string expr = "123/(12*3)"; And I want to actually calculate the mathematical expression in the string. Is there an easy way do it? Or do I have to extract all...
10
by: Christopher Benson-Manica | last post by:
(if this is a FAQ, I apologize for not finding it) I have a C-style string that I'd like to cleanly separate into tokens (based on the '.' character) and then convert those tokens to unsigned...
6
by: Allan Bruce | last post by:
I have a string like: "FL:1234ABCD:3:FileName With Spaces.txt\n" and I want to read the values separated by ':' into variables. I tried to use sscanf like this: sscanf("FL:%s:%d:%s\n",...
1
by: Sandra | last post by:
I am trying to convert a string into a uniqueidentifier by using the following code string contrID = Request.Params["oId" SqlGuid sqlID = SqlGuid.Parse(contrID I am then putting sqlID into my...
3
by: Ryan Ternier | last post by:
Customers keep getting this error, but we've never been able to re-produce it. Any help on this would be awesome. Here's the error message we get. Date and Time Occured: Wednesday, June...
1
by: amitbadgi | last post by:
I am gettign this error, while migration an app to asp.net Exception Details: System.FormatException: Input string was not in a correct format. Source Error: Line 19: Dim enddate =...
2
by: sam.barker0 | last post by:
Hi guys, I am trying to form an IPV6 address string from the address bytes contained in a unsigned char buffer char tempstring; sprintf(tempstring, "%x:%x:%x:%x:%x:%x:%x:%x",htons(*((unsigned...
6
by: James Arnold | last post by:
Hello, I am new to C and I am trying to write a few small applications to get some hands-on practise! I am trying to write a random string generator, based on a masked input. For example, given...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.