V22.0101, Homework Assignment 5, Spring 2006
Sorting a Database
Assigned:WED NOV 12
Due: TUE APR 25, 11:59pm. No projects will be accepted after that and there will be no resubmissions.
Final Exam: MON MAY 8 10:00-11:50 in 109 WWH
In this project you are asked to write a program that sorts the records of a database on a given field. The link to the data base is directly beneath this link. The first few records are:
marin gil 269972639 34 abrams rita 005456788 17 nottobe tobe 029209330 19 backus jim 379228370 23
The first field of the record contains the person's last name; the second field, the first name; the third, the social security numer; and the fourth, the person's age. If the records are sorted on the fourth field, the results would be:
abrams rita 005456788 17 nottobe tobe 029209330 19 backus jim 379228370 23 marin gil 269972639 34
We will call the entries in the records tokens. One or more blanks separate the tokens from each other. To enable your program to distinguish the tokens in a record, use the StringTokenizer class (see page 274 in the text).
Here are the steps you should follow to write the program:
Your program should sort on a key read by your program. Your program should be
robust throughout. If the key is out of range, your program should indicate
this. After the sort is done, your program should ask whether the user wants to
continue, just as in the craps game. If the user types any input other than y
or n, the program should inform him/her of the error and request new input.