Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Number conversion

Posted on 1997-10-21
3
137 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying 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

Is your phone running out of space to hold pictures?  This article will show you quick tips on how to solve this problem.
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
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 …

789 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