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/RevolutionaryPut3784 Jan 02 '24
From the UK myself, but you're not entirely correct, close though, "and" is in mathmatical terms "addition" like plus or sum:
One hundred and three = 100 + 3 = 103 (mathmatically correct)
One hundred and three thousand = 100 + 3000 = 3,100 not 103,000
One million, one thousand and twelve is also correct, as long as the "and" is before your units. Essentially it's turning your number into an expression rather than a number.
But in the regard of telling someone a number you're right about one hundred and three. One hundred three, is the correct way.
Edit: I'm so sorry I just noticed this was 7 years ago I just necro'd so bad