Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

shit challenge: numerics to words

Name: Anonymous 2010-07-25 3:01

Weekly Challenge: Programmatically convert any1 string of digits, such as "1234567" to word form, "one million, two hundred thirty-four thousand, five hundred sixty-seven"

Here is mine: http://codepad.org/gyqbaKxx

Criticize my code.  I know it sucks anus.  I would like to make it better.  Submit your own versions as well.

Use whatever language you like[i]!/i]

_____________________________________
1. Up to 18 significant digits is fine.

Name: Anonymous 2010-07-27 23:41


package org.4chan.dis.read.prog._1280041293._62;

public class Numerics2Words
{ public static final String[] words = {"", "one", "two", "three", "four", "five",
                                        "six", "seven", "eight", "nine"};
 
  public static void main(String... args)
  { if (args.length < 1)
    { throw new IllegalArgumentException("Usage: java Numerics2Words ");
 
    final String numeric = args[0];
    final StringBuilder result = new StringBuilder();
    for (int i = 0; i < numeric.length; i++)
    { final char c = numeric.charAt(i);
      result.append(words[Integer.parseInt(c).intValue()]);   
    }
   
    System.out.println(result.toString());
  }
}

Name: Anonymous 2010-07-28 0:08


Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List