Due: 5:00pm, Friday, September 12. Value: 40 pts.
To help with advertising phone numbers, many companies and people
prefer to associate some word with their telephone number, such as
1-800-DOMINOS for Domino's Pizza or 1-800-TAX-I-WEEP for the Internal
Revenue Service. Since phone numbers aren't very conducive to the
task, a standard trick is to advertise a fake
letter onto the
end, which can still be dialed but will be ignored; this is how the
Internal Revenue Service gets away with TAX-I-WEEP, which actually
has 8 digits.
Your job is to write a program that reads a phone number from the user and displays any English mnemonics it can find. You should account for the extra-letter trick outlined above. Your program must use recursion to search through all possible letter sequences that can be generated by the telephone number; thus, it should also work for numbers of more or fewer than seven digits. (An alternative approach — which is forbidden for this assignment — is to go through the dictionary looking for words that match with the telephone number.) Note that need only identify one-word values, not multiple-word combinations like TAX-I-WEEP.
Use the now-standard digit-to-letters encoding:
2: ABC
3: DEF
4: GHI
5: JKL
6: MNO
7: PQRS
8: TUV
9: WXYZ
Note that this means that a 0 or a 1 in a telephone number will immediately destroy any possibility of a mnemonic from your program.
To get you started, I'm providing a PhoneMnemonics.java, which provides the overall user interface. You should not modify this code, aside from completing its computeMnemonics method and adding new static methods. You should not add any static variables (unless they're final), instance variables, or instance methods.
By default, the distributed program uses a dictionary available on Linux computers. If you're working on your own computer, you may need a dictionary file; you can work with this dictionary.