import java.io.*;
public class Name{
public static void main(String [] args) throws IOException {
BufferedReader keyboard = new BufferedReader(
new InputStreamReader(System.in));
final String[] MENNAMES = {"Elroy","Fred","Graham"};
final String[] LADYNAMES = {"Amy","Buffy","Cathy"};
System.out.print("Enter a name: ");
String inputName = keyboard.readLine();
while(inputName.length()!=0){
boolean notDone = true;
for(int i = 0; i<MENNAMES.length&¬Done; i++){
String familyName = inputName.substring(0,inputName.indexOf(" "));
if(familyName.equals(MENNAMES[i])){
System.out.println("Mr. "+inputName);
notDone = false;
}
else if(familyName.equals(LADYNAMES[i])){
System.out.println("Ms. "+inputName);
notDone = false;
}
}
if(notDone)
System.out.println(inputName);
System.out.print("Enter a name: ");
inputName = keyboard.readLine();
}
}
}
//随便写了一下,可能有错误,呵呵,多多指教

