xhtml
 

Hint

To complete the units function, you need to make a decision about what string to return, based on the argument, so you can write the function in this style:

// Convert a single-digit number u into a word, where 0 <= u <= 2.
String units(int u)
{
   String result;
   if (u == 0) result = ...;
   else if (u == 1) result = ...;
   else if (u == 2) result = ...;
   else result = "?";
   return result;
}

Then you can complete tens, then teens, then hundreds in the same sort of way.


Back