Originally Posted by
silent-kill
first you need to store:
array1 = one, two, three, four, five, six, seven, eight, nine, zero
array2 = ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eighteen, nineteen,
array3 = ten, twenty, thirty, fourty, fifty, sixty, eighty, ninety,
array4 = hundred
array5 = thousand
no need array4 and array5.
PHP Code:
seven hundred ninety two
seven hundred ninety four
seven hundred ninety six
seven hundred ninety eight
eight hundred
eight hundred two
eight hundred four
eight hundred six
eight hundred eight
eight hundred ten
eight hundred twelve
eight hundred fourteen
eight hundred sixteen
eight hundred eighteen
eight hundred twenty
eight hundred twenty two
eight hundred twenty four
eight hundred twenty six
eight hundred twenty eight
eight hundred thirty
PHP Code:
one thousand four hundred thirty six
one thousand four hundred thirty eight
one thousand four hundred forty
one thousand four hundred forty two
one thousand four hundred forty four
one thousand four hundred forty six
one thousand four hundred forty eight
one thousand four hundred fifty
one thousand four hundred fifty two
one thousand four hundred fifty four
one thousand four hundred fifty six
one thousand four hundred fifty eight
one thousand four hundred sixty
one thousand four hundred sixty two
I hope you get what I mean, on my output.
for future, you need million, billion, trillion........................................to whatever lion is that
this is how I solve it"
-get input
-divide your input to extract ones, tens, hundreds and thousands.
-use switch/if then else to
-ones, tens, hundreds, and thousands
-and convert them to string equivalent.
-concatenate each string
-output concatenated string
I suggest to convert it to string directly or group your digits by three, so you will have a better performance when talking about large numbers.