Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Translating numbers into words

Translating numbers into words

Translating numbers into words

Hey folks,

We just started with scheme at the university and I need some help doing my task.

We shall write a program that translates numbers into words, e.g 1 to "one". It must work for all numbers up to 10 ^ 9.
I've got no real clue how to do this... My basic idea would be to create some sort of array or list where I define those numbers as words like this:

('ZERO',    0)
('ONE',            1)
('TWO',      2)
('THREE',    3)
('FOUR',    4)
('FIVE',    5)
('SIX',     6)
('SEVEN',    7)
('EIGHT',    8)
('NINE',    9)
('TEN',     10)
('ELEVEN',    11)
('TWELVE',    12)
('THIRTEEN',    13)
('FOURTEEN',    14)
('FIFTEEN',    15)
('SIXTEEN',    16)
('SEVENTEEN',    17)
('EIGHTEEN',    18)
('NINETEEN',    19)
('TWENTY',    20)
('THIRTY',    30)
('FORTY',    40)
('FIFTY',    50)
('SIXTY',    60)
('SEVENTY',    70)
('EIGHTY',    80)
('NINETY',    90)
('HUNDRED',    100)
('THOUSAND',    1000)
('MILLION',     1000000)
('BILLION',     1000000000)
('TRILLION',    1000000000000)
('QUADRILLION', 1000000000000000)

Then somehow check the input value with this list and substitute the numbers with the words. But implementing this is giving me some trouble. Hope someone can help :)


RE: Translating numbers into words

Thats Python though. How does it work in scheme? Apparently the guy has the same idea :D

RE: Translating numbers into words

Recursive method. When do you stop recursion ?
You study (quotient N 1000) and (modulo N 1000).
You must memorize the state (unit, thousand, million ...).  

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close