Results 1 to 6 of 6
  1. #1
    syntrax is offline Member
    Join Date
    Sep 2009
    Location
    http://www.kouje.com
    Posts
    16
    Rep Power
    0

    Unhappy 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. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    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. #3
    [RaIdEn] is offline Senior Member
    Join Date
    Oct 2009
    Location
    California,US
    Posts
    201
    Rep Power
    6

    Default

    you can use scanner for reading user input right?

  4. #4
    jefrazie is offline Member
    Join Date
    Oct 2009
    Posts
    7
    Rep Power
    0

    Default

    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. #5
    Lizzip is offline Member
    Join Date
    Oct 2009
    Posts
    12
    Rep Power
    0

    Default

    EDIT: Accidental double post :/ Don't know how to delete it, sorry
    Last edited by Lizzip; 10-22-2009 at 04:35 PM.

  6. #6
    Lizzip is offline Member
    Join Date
    Oct 2009
    Posts
    12
    Rep Power
    0

    Default

    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

Similar Threads

  1. [SOLVED] HashMap & Spell checking
    By Dana Zra in forum New To Java
    Replies: 5
    Last Post: 10-19-2008, 10:05 PM
  2. printing two smallest numbers from a series of numbers
    By trofyscarz in forum New To Java
    Replies: 2
    Last Post: 10-15-2008, 12:46 AM
  3. Spell check in Textarea.
    By surya_dks in forum Advanced Java
    Replies: 2
    Last Post: 08-22-2008, 01:33 AM
  4. Spell check feature
    By ravian in forum Advanced Java
    Replies: 2
    Last Post: 12-27-2007, 10:28 AM
  5. spell check
    By kazitula in forum Java Applets
    Replies: 2
    Last Post: 12-20-2007, 12:37 PM

Posting Permissions

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