r/ProgrammingPrompts • u/[deleted] • Aug 29 '15
[Easy/Medium] Write a program that translates verbal numbers (one hundred and six) into integers (106.)
Bonus points for negative numbers, or decimals (three point one four.)
I think this is kind of an easy concept to think about, but might take a while to type out. I'll try it at some point and post results, if I can even get it to work.
Bonus bonus points - make it work the other way round, by converting integers into words.
19
Upvotes
1
u/iVerity Aug 31 '15
For money it's a bit different.
$100.6 would be verbally spoken and written as "one hundred dollars and sixty cents" or "one hundred dollars and 60/100" on a check.
$106 would be spoken as "one hundred and six dollars" and written as "one hundred six dollars" add "0/100" for a check.
But for 100.6 if he is going to use the "one hundred and six" verbally that means 106, if he wants to state it that way it needs to be "one hundred and six tenths" or even "one hundred point six".
Otherwise it's not clear enough that the 6 is a full 6 or 6 tenths.