Solved

Number conversion

Posted on 1997-10-21
3
134 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This article will show you how to create an ISO CD-ROM/DVD-ROM image (*.iso), and MD5 checksum signature, for use with VMware vSphere Hypervisor 6.5 (ESXi 6.5). It's a good idea to compare checksums, because many installations fail because of a corr…
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now