Thread: Translate number to sentence

  1. #1
    unleashed alphaoide's Avatar
    Join Date
    Sep 2003
    Posts
    696

    Translate number to sentence

    Goal:
    Translates , say, "2004" to "two thousand four"

    Implementation:
    Will have different cases for: 0-9 ([blank], one, two, ..., nine)
    0x-9x ([blank], ten, twenty, thirty,..., ninety)
    100 up is rather easy, if there are 3 digits determines the case for first digit, say "143" would be "one" and then add "hundred", and then look up 4x ("forty"), and last is "three"

    Sounds like a plan?

    EDIT:
    hmm...should I say "twelve hundred" or "one thousand two hundred" for "1200" ??
    Last edited by alphaoide; 09-29-2004 at 01:22 AM.
    source: compsci textbooks, cboard.cprogramming.com, world wide web, common sense

  2. #2
    Registered User
    Join Date
    Sep 2004
    Posts
    27
    Depends on how simple you want it. One thousand two hundred would be much easier than twelve hundred... else you'd have to do other checks and such.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. vector<...>::iterators and insert - I'm stumped.
    By Dino in forum C++ Programming
    Replies: 6
    Last Post: 12-25-2007, 06:11 AM
  2. adding a number to a number
    By bigmac(rexdale) in forum C Programming
    Replies: 11
    Last Post: 10-24-2007, 12:56 PM
  3. scanf oddities
    By robwhit in forum C Programming
    Replies: 5
    Last Post: 09-22-2007, 01:03 AM
  4. Finding a number within a number
    By jeev2005 in forum C Programming
    Replies: 2
    Last Post: 01-10-2006, 08:57 PM
  5. Random Number problem in number guessing game...
    By -leech- in forum Windows Programming
    Replies: 8
    Last Post: 01-15-2002, 05:00 PM