# Thread: How to Spell out numbers?

1. Member
Join Date
Sep 2009
Location
http://www.kouje.com
Posts
16
Rep Power
0

## How to Spell out numbers?

I've been trying, this entire weekend on how to make a program that reads number inputed by a user, from 0.00 to 999.99... and i just can't figure it out!!!!! i know it seems easy but i swear, i just can't, everything i try just dont work. I'm not asking for a program that already works (tho very much appreciated :p) but just point me out in the correct direction.

I tried converting the numbers in to Chars, then using the ASCII table to assign them to letters and then use if else statements and that just doesn't work... help!:confused:

ty very much.

2. It's always best for you to show us your best attempt at solving this first. This way, we can work with you with your code, and we can see what assumptions you are making that need correcting. Also, when posting code, please use code tags (see below), and please describe in as much detail as necessary how the program doesn't work right.

Much luck!

3. Senior Member
Join Date
Oct 2009
Location
California,US
Posts
201
Rep Power
11
you can use scanner for reading user input right?

4. Member
Join Date
Oct 2009
Posts
7
Rep Power
0
An approach i would use would be to import each number as a string, then tokenize that string. Compare each value that was tokenized to another string containing the "word" representation of numbers.

5. Member
Join Date
Oct 2009
Posts
12
Rep Power
0
EDIT: Accidental double post :/ Don't know how to delete it, sorry
Last edited by Lizzip; 10-22-2009 at 03:35 PM.

6. Member
Join Date
Oct 2009
Posts
12
Rep Power
0
I think you're over-complicating it.

Firstly make 3 arrays, one for hundreds, one for tens and one for ones.
So in array one, it has numbers such as one, two, three etc
Array tens has numbers such as ten, twenty, thirty and so on

Take the user's inputted number (say, 192.53) then separate numbers before and the numbers after into two seperate strings ("192" and "53"). Then seperate these into individual strings for each number. Then use some sort of string compare combined with which array it falls into to figure out which number you should write out.

You're not always going to get the best grammar with this way, but still..it works

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•