Our student data is a mess! Each student is described with one String. At least
a student's data always starts with her name, then her age, and then her
address, and none of these is ever missing. The name and age are separated by one or more
spaces and the age is separated from the address by one or more spaces. There may be leading and trailing spaces in a student's data.
A student's name always consists
only of uppercase letters 'A'-'Z' and
embedded (not leading or trailing) spaces. A student's age always consists of exactly 1, 2, or 3 digits, and its leading digit is not a zero. A student's address always contains at least one non-space character.
We need to find the name of the oldest student. If there are several, we want
the one that appears earliest in the data. The name should include its embedded
spaces (even if there are several consecutive embedded spaces), but no leading
spaces and no trailing spaces.
Create a class OldestOne that contains a method oldest that is given a String[]
data where each element is the data for a student, and that returns the
name of the oldest student.
|