PDA

View Full Version : Program help!!!!


1tss
09-16-2009, 04:34 PM
Please help with the following:

write a program which reads people's names from a data file. Each name will have one of the following forms:

firstname lastname
firstname initial. lastname
firstname middlename lastname

After reading the names, the program will prompt the user at the keyboard to enter the first letter of the last name. The program will then print all people whose last names start with the given letter. When a name is printed, it will have one of the following forms:

lastname, firstname
lastname, firstname initial.
lastname, firstname middlename

Use a loop so that the program will continue to prompt for first letters until a non-alphabetic character is entered.

Make sure that your program allows the user to search for names beginning with different letters. After reading and storing the names, the program will prompt the user at the keyboard to enter the first letter of the last name. The program will then print all people whose last names start with the given letter. After the names starting with that letter have printed, the program should prompt for another letter, and print the names starting with the new letter. This should continue until the user enters a non-alpha character.
Some Details

* Create a Person class. Each Person object will contain one name. Store the name in three parts, not as one String. Use StringTokenizer to separate the name into parts.
* In main, create an array of Person objects to hold the names. Make the array large enough to hold 50 objects.
* Write a method in Person that will return the name in the format needed for the output.
* Think about what the Person class needs to provide so that main (or a static function called from main) can check whether a Person's last name starts with a given letter.
* Like all classes, your Person class should have a toString method and an equals method. And don't forget about constructors.
* All I/O should take place in the client code (main or a static function called by main.) No I/O should be done in the Person methods.

ckeyrouz
09-16-2009, 04:35 PM
No homework to be done here.
Post code and we help you correct problems in it.