Representing Names

  1. Write a class, Name, that stores a person's first, middle, and last names and provides the following methods:
  2. Now write a program TestNames.java that prompts for and reads two names from the user (you'll need first, middle, and last for each). The input should be in the form "firstName middleName lastName" (i.e., three words separated by spaces). The program should create a Name object for each, and use the methods of the Name class to do the following:
    1. For each name, print its
      • first-middle-last version (by using Name.lastFirstMiddle)
      • last-first-middle version (by using Name.firstMiddleLast)
      • initials (by using Name.initials)
      • length (by using Name.length)
    2. Tell whether or not the names are the same by using Name.isEqual. If the two names are not equal, the output should be something like, "Franklin Delano Roosevelt is not George W Bush" (this assumes the user provided "Franklin Delano Roosevelt" for the first name and "George W Bush" as the second). If the names are equal, the output should use "is" instead of "is not": e.g., "Franklin Delano Roosevelt is FRANKlin DElano Roosvelt". This assumes the user provided "Franklin Delano Roosevelt" for the first name and "FRANKlin DElano Roosvelt" as the second. Recall that our equality test ignores upper/lower case.)

Your lab document should contain sample output of your program where the two names are the same, and then when the two names differ.

Submit a zip file, names.zip, consisting of your lab document and the Name.java and TestNames.java files.