Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Numbers to Words
- Write a method Letterize(number) which accepts a number and prints it as words, according to these conditions:
- If the number is more than 999 you should print – "too large"
- If the number is less than -999 you should print – "too small"
- If the number is negative, you should print "minus" before it.
- If the number does not have 3 digits, do not print it
- The program should accept an integer N. On the next N lines, you should accept numbers and print them as words.
- Examples
- Input
- Output
- Input
- Output
- 3
- 999
- -420
- 1020
- nine-hundred and ninety nine
- minus four-hundred and twenty
- too large
- 2
- 15
- 350
- three-hundred and fifty
- Input
- Output
- Input
- Output
- 4
- 311
- 418
- 519
- -9945
- three-hundred and eleven
- four-hundred and eighteen
- five-hundred and nineteen
- too small
- 2
- 500
- 123
- five-hundred
- one-hundred and twenty three
- Hints
- 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: “”, “”, “”.
- 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: “”, “”, “”
- 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