The SOUNDEX code was devised by Margaret K.Odell and Robert C.Russell [US Patent 1261167 (1918) 1435663 (1922)]. The purpose of the SOUNDEX system is to classify together names that have similar sounds. It was used starting with the FD Roosevelt presidency to facilitate collection, collation, and retrieval of citizen's census information. (The algorithm is case insensitive, so we can and should convert all letters to uppercase.)
Here is the SOUNDEX algorithm as reported by Donald Knuth [The Art of Computer Programming, Volume 3]:
Here are examples of applications of the Soundex algorithm (also from Knuth):
Euler -> E460 Gauss -> G200 Hilbert -> H416 Knuth -> K530 Lloyd -> L300 Lukasiewicz -> L222 Pfister -> P236
Write a class Soundex whose main function
in a loop prompts the user to enter a name
and then prints out the soundex code for that name. The loop terminates when
the name entered is the empty string.
Implement and
use in your program the method
static String getSoundex(String s);that returns the soundex code of s.
static char encode(char c);which maps 'B','F','P','V' to '1', 'C','G',..'Z' to '2', ..., 'R' to '6', and 'A','E','H','I','O','U','W','Y' to '0'.
Be sure to document your code and to write your name in the java file.