JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
How about this idea, if the number is less than 20, use an array of 0 to 19 to show the results.
Otherwise: show the tens stuff and if there is a ones digit, show a hyphen and the one digit.
JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Get and parse the number from the command line
Get the tens digit by calculating
Get the ones digit by calculating
If
the number is less than 20, pick the right word from the array containing the ones and teens
Otherwise
Pick the right word from the array containing the tens
If the ones digit is not zero, print a hyphen and pick the right word from the array containing the ones and teens
Marilyn suggest:
"Notice how you print tensName[ divArgs ] ) in both
the else if block and the else block.
Maybe you can think of a way to consolidate this code."
"Happiness is a way to Travel, <b>Not</b> a Destination" -- Unknown
Consider Paul's rocket mass heater. |