Number in words

Write a program that takes an integer and displays the words number of that value. For example,
10->ten
121->one hundred twenty one

Questions by dhairaybablani

Showing Answers 1 - 1 of 1 Answers

Subrata Laha

  • Jul 25th, 2014
 

Please see the below code in Java

Code
  1. span style="color: #006699;">java.text.DecimalFormat"",

  2.     " ten",

  3.     " twenty",

  4.     " thirty",

  5.     " forty",

  6.     " fifty",

  7.     " sixty",

  8.     " seventy",

  9.     " eighty",

  10.     " ninety""",

  11.     " one",

  12.     " two",

  13.     " three",

  14.     " four",

  15.     " five",

  16.     " six",

  17.     " seven",

  18.     " eight",

  19.     " nine",

  20.     " ten",

  21.     " eleven",

  22.     " twelve",

  23.     " thirteen",

  24.     " fourteen",

  25.     " fifteen",

  26.     " sixteen",

  27.     " seventeen",

  28.     " eighteen",

  29.     " nineteen"" hundred"// 0 to 999 999 999 999

  30. "zero"// pad with "0"

  31. "000000000000"// XXXnnnnnnnnn

  32. // nnnXXXnnnnnn

  33. // nnnnnnXXXnnn

  34. // nnnnnnnnnXXX

  35. """ billion "" billion """" million "" million """"one thousand "" thousand "// remove extra spaces!

  36. "^\s+", "").replaceAll("\b\s{2,}\b", " ");

  37.   }

  38.  

  39.   /**

  40.    * testing

  41.    * @param args

  42.    */"*** ""*** ""*** ""*** ""*** ""*** ""*** ""*** ""*** ""*** ""*** ""*** ""*** ""*** ""*** ""*** ""*** ""*** ""*** "/*

  43.      *** zero

  44.      *** one

  45.      *** sixteen

  46.      *** one hundred

  47.      *** one hundred eighteen

  48.      *** two hundred

  49.      *** two hundred nineteen

  50.      *** eight hundred

  51.      *** eight hundred one

  52.      *** one thousand three hundred sixteen

  53.      *** one million

  54.      *** two millions

  55.      *** three millions two hundred

  56.      *** seven hundred thousand

  57.      *** nine millions

  58.      *** nine millions one thousand

  59.      *** one hundred twenty three millions four hundred

  60.      **      fifty six thousand seven hundred eighty nine

  61.      *** two billion one hundred forty seven millions

  62.      **      four hundred eighty three thousand six hundred forty seven

  63.      *** three billion ten

  64.      **/

  65.   }

  66. }

  67.  

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions