CSC 172
Homework assignment 2

Assigned 9 Feb, 1999
Due 25 Feb, 1999

More practice with loops

Enough with the Buggles for a moment.  This assignment, while it doesn't give you pretty colored Buggles racing around the screen, allows you to practice some of the kinds of processing of multiple objects that are done all the time in business and science.

Write a Java Application named HW2 (main class HW2, file HW2.java, etc. etc.  Consistent naming just makes it easier for me to grade the things.)
The program is to prompt the user to type in a sequence of names, each of which consists of a first and a last name.  There should be a clear, easy way for the user to indicate when the list of names is finished, e.g. just hitting RETURN when asked for a first name.  The program will then print out various information about the list of names:

Hints:

Examples:

Please type in a list of names.  When you're done, just hit RETURN when asked for another name.

First name?
No first name.  Do you want to enter a last name?no
Thank you.  Here's some information about that list of names.
There were no names in the list.
Please type in a list of names.  When you're done, just hit RETURN when asked for another name.
First name?Stephen
Last name?Bloch
First name?
No first name.  Do you want to enter a last name?no
Thank you.  Here's some information about that list of names.
The shortest first name was Stephen.
The longest first name was Stephen.
The average length of a first name was 7.0, and no first names were longer than that.
The earliest name in alphabetical order was Stephen Bloch.
The last name in alphabetical order was Stephen Bloch.
Please type in a list of names.  When you're done, just hit RETURN when asked for another name.
First name?Joe
Last name?Schmoe
First name?Stephen
Last name?Bloch
First name?Annie
Last name?Schmoe
First name?Edward
Last name?Beeblebrox
First name?
No first name.  Do you want to enter a last name?no
Thank you.  Here's some information about that list of names.
The shortest first name was Joe.
The longest first name was Stephen.
The average length of a first name was 5.25, and 2 first names were
longer than that.
The earliest name in alphabetical order was Edward Beeblebrox.
The last name in alphabetical order was Joe Schmoe.

Please type in a list of names.  When you're done, just hit
RETURN when asked for another name.
First name?Billy
Last name?Bob
First name?
No first name.  Do you want to enter a last name?yes
Last name?Somebodywithnofirstname
First name?Jim
Last name?Bob
First name?Nolastname
Last name?
No last name.  Do you want to use this name anyway?yes
First name?
No first name.  Do you want to enter a last name?no
Thank you.  Here's some information about that list of names.
The shortest first name was .
The longest first name was Nolastname.
The average length of a first name was 4.5, and 2 first names were
longer than that.
The earliest name in alphabetical order was Nolastname .
The last name in alphabetical order was  Somebodywithnofirstname.


Last modified: Tue Feb 16 15:45:25 EST 1999
Stephen Bloch / sbloch@adelphi.edu