473,748 Members | 3,697 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

String converting to Stack/ Parsing

1 New Member
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 4403
Frinavale
9,735 Recognized Expert Moderator Expert
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
3626
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" -zug into: ,
2
2372
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 the parts from the string, which will be difficult since the expression will change in my app..
10
2633
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 integers. What is the best standard(!) C++ way to accomplish this? -- Christopher Benson-Manica | I *should* know what I'm talking about - if I ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
6
18521
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", lGuid, &lID, lFileName); but the lGUID just continues until whitespace or \0 is found. I need a way
1
9624
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 SQL WHERE clause so it only pulls that record. I've double checked that the record I'm trying to pull is in the database. I am getting the error below. I don't understand what is causing it, Any Help is appreciated!!!!!! ArgumentNull_String...
3
6635
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 01, 2005 11:02:20 AM
1
2852
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 = request.QueryString("enddate") Line 20: Line 21: if cint(eventid) = "0" then
2
4584
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 short *)(buf.GetStart()))),htons(*((unsigned short *)(buf.GetStart() +2))),htons(*((unsigned short *)(buf.GetStart()+4))),htons(*((unsigned short *)(buf.GetStart()+6))),htons(*((unsigned short *)(buf.GetStart() +8))),htons(*((unsigned short...
6
3516
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 the string: "AAANN" it would return a string containing 3 alphanumeric characters followed by 3 digits. This part I have managed:) I would now like to add some complexity to this, such as repetitions and grouping. For example, I'd like to have...
0
8989
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
9319
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9243
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8241
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6795
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4599
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3309
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2213
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.