Final answer:
To solve this problem, we can create three separate methods: digitToWord(), tensDigitToWord(), and twoDigitNumToWords(). The digitToWord() method takes a single digit number from 0-9 and returns that number's word. The tensDigitToWord() method takes a single digit number from 2-9 and returns that number's word when it appears in the tens digit. The twoDigitNumToWords() method takes a two-digit number from 20-99 and returns that number in words.
Step-by-step explanation:
To solve this problem, we can create three separate methods: digitToWord(), tensDigitToWord(), and twoDigitNumToWords().
The digitToWord() method takes a single digit number from 0-9 and returns that number's word. We can use a switch statement to check the input number and return the corresponding word.
The tensDigitToWord() method takes a single digit number from 2-9 and returns that number's word when it appears in the tens digit. Again, we can use a switch statement to check the input number and return the corresponding word.
The twoDigitNumToWords() method takes a two-digit number from 20-99 and returns that number in words. We split the number into its tens and ones digits and call the tensDigitToWord() method to get the word for the tens digit, and then call the digitToWord() method to get the word for the ones digit.
Finally, in the main program, we can get the user's input integer, call the twoDigitNumToWords() method, and output the resulting string.