Solved

Number conversion

Posted on 1997-10-21
3
138 Views
Last Modified: 2010-04-16
Please provide the algorithm for converting a three-digit number in words into numeric output. Ex.:
Input: two hundred thirty-five
Output: 235

P.S. I'm using Turbo Pascal 7.0
0
Comment
Question by:chadd082197
3 Comments
 
LVL 2

Expert Comment

by:kellyjj
ID: 1216329
You want source code for something like this? For only 50 points?  Better increase the points.  Is this some kind of hw assignment for school
0
 
LVL 9

Accepted Solution

by:
cymbolic earned 50 total points
ID: 1216330
Chadd, let me just give you a general approach to the solution.

1) you need a token parser to examine your string input line, separating out individual number names and Significance names (Like hundred)

You need a table of string names, with their equivalent number strings e.g. (FIVE:5) and (HUNDRED:). Some tokens you need to just eliminate.

Then, you can loop through the input string, on each pass select the next token (substring/word) off the input string,
find this in your table, and add the number string (if any) to you resultant output string.

When out of tokens, either display output string at this point, or
process it further, counting back by threes, and inserting commas, then dispay.

Try it, it's not so hard!

0
 

Author Comment

by:chadd082197
ID: 1216331
Thanks for replying.... I'm increasing the points because I need a bit more explaining done, maybe some pseudocode (if not the actual code). We haven't really gotten into arrays yet, so if there's a simple way of doing this with control loops (return, for, while, case, etc) and strings, that's what I need. Thanks!


0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

While it may be true that the internet is a place of possibilities, it is also a hostile environment lurking with many dangers. By clicking on the wrong link, trusting the wrong person or using a weak password, you are virtually inviting hackers to …
Arrow Electronics was searching for a KVM  (Keyboard/Video/Mouse) switch that could display on one single monitor the current status of all units being tested on the rack.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question