Problem B
Words for Numbers
We have two ways of writing out numeric values; we can print them in decimal form, like 45, or we can write them out in text, like forty-five. You are a court reporter who gets paid by the character, so you would always prefer to write out numbers the long way. To that end, you are going to make sure all of your documents have decimal values written out in text rather than numbers, even if you have to get a program to help you do it.
Input
Input consists of up to $100$ lines of text, ending at the end of file. All input string tokens are separated by single spaces. Each token is either a decimal number or a string of alphabet (a–z, A–Z) or simple punctuation characters. Decimal numbers in the input are integers in the range $[0,99]$. There are at most $100$ tokens per line, and all tokens have a length of at most $15$ characters.
Output
For each line of text in the input, print out a modified version of that line with all occurrences of decimal numbers replaced with words. For each decimal number you find, replace it with hyphen-separated English words representing the same value. Numbers that occur at the start of a line should start with an uppercase letter.
Sample Input 1 | Sample Output 1 |
---|---|
The speed limit is 40 mph, but you were going over 65 99 bottles of ... |
The speed limit is forty mph, but you were going over sixty-five Ninety-nine bottles of ... |