CIS 1068: Homework 6

(Tuesday-Thursday)Handed out: 10/07/2008, Due: by 10pm on 10/13/2008
(Monday-Wednesday)Handed out: 10/08/2008, Due: by 10pm on 10/15/2008
Email program to TA

The New York State Identification and Intelligence System (NYSIIS) is a variant of the SOUNDEX phonetic code. It is intended to represent with the same code (also called key) names that have similar sounds. It was used by the New York State Division of Criminal Justice Services.

The algorithm is case insensitive, so we can and should convert all letters to the same case, say, uppercase.

Here is the algorithm


   1. Translate first characters of name: MAC -> MCC, KN -> NN, K -> C, PH -> FF, 
	PF  -> FF, SCH -> SSS else first character of key =
	first character of name
   2. Translate last characters of name: EE -> Y, IE -> Y, 
	DT, RT, RD, NT, ND -> D, AY -> Y
   3. If the last character is A or S, remove it
   4. Translate remaining characters from left to right by following rules:
         1. SCH -> SSS, PH -> FF
         2. KN -> NN else K -> C 
         3. EV -> AF else A, E, I, O, U -> A 
		character
         4. Q -> G, Z -> S, M -> N 
         5. H -> If previous or next is nonvowel, previous.
         6. W -> If previous is vowel, previous.
         7. Add current to key if current is not same as the last key character.

Write a class Nysiis whose main function in a loop prompts the user to enter a name and then prints out the NYSIIS code for that name. The loop terminates when the name entered is the empty string.
Define the method

	public static String getNysiis(String s);
that returns the NYSIIS code of s.

You can verify your implementation against the behavior of this program

Be sure to document your code and to write your name in the java file.