Advertisement
Sim0o0na

Untitled

Jun 15th, 2017
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. Numbers to Words
  2.  
  3. Write a method Letterize(number) which accepts a number and prints it as words, according to these conditions:
  4.  
  5. If the number is more than 999 you should print – "too large"
  6. If the number is less than -999 you should print – "too small"
  7. If the number is negative, you should print "minus" before it.
  8. If the number does not have 3 digits, do not print it
  9. The program should accept an integer N. On the next N lines, you should accept numbers and print them as words.
  10.  
  11. Examples
  12.  
  13. Input
  14.  
  15. Output
  16.  
  17.  
  18.  
  19. Input
  20.  
  21. Output
  22.  
  23. 3
  24.  
  25. 999
  26.  
  27. -420
  28.  
  29. 1020
  30.  
  31. nine-hundred and ninety nine
  32.  
  33. minus four-hundred and twenty
  34.  
  35. too large
  36.  
  37. 2
  38.  
  39. 15
  40.  
  41. 350
  42.  
  43. three-hundred and fifty
  44.  
  45.  
  46.  
  47. Input
  48.  
  49. Output
  50.  
  51.  
  52.  
  53. Input
  54.  
  55. Output
  56.  
  57. 4
  58.  
  59. 311
  60.  
  61. 418
  62.  
  63. 519
  64.  
  65. -9945
  66.  
  67. three-hundred and eleven
  68.  
  69. four-hundred and eighteen
  70.  
  71. five-hundred and nineteen
  72.  
  73. too small
  74.  
  75. 2
  76.  
  77. 500
  78.  
  79. 123
  80.  
  81. five-hundred
  82.  
  83. one-hundred and twenty three
  84.  
  85. Hints
  86.  
  87. The first set of special cases comes when a number’s right on the hundreds (i.e. 100, 200, 300, etc.). Print them like this: “”, “”, “”.
  88. The second set of special cases comes when a number’s last 2 digits are less than 10 (i.e. 101, 305, 609, etc.). Print them like this: “”, “”, “”
  89. The third set of special cases comes when a number is in the teens (i.e. 111, 814, 919). Print them like this: “”, “”, “”
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement