A user has entered a list of Strings. We must check each String to see if it
meets our criteria for a "customer", and either reject the String or
recapitalize and respace it to meet our standards.
Our formatting manual states: -
A well-formed customer consists of either 2 or 3 parts. The parts are separated by
one or more spaces, but there are no leading spaces or trailing spaces.
Each part must be a name or an initial, but the last part may not be an initial.
An initial is a letter ('a-z' or 'A-'Z') followed by a period ('.')
A name is a sequence of two or more letters ('a-z' or 'A'-'Z').
Our standard for recapitalizing a well-formed customer is that each name or initial
should start with an uppercase letter and all other letters should be lowercase.
Our standard for respacing a well-formed customer is that any extra spaces
between parts should be removed leaving
exactly one space between adjacent parts.
Create a class NameCheck that contains a method formatList that is given a
String[] namelist and that returns a String[] that includes all the well-formed customers,
properly recapitalized and respaced. They should appear in the same order as in
the original namelist.
|