Assignment #8: Linked List and Pointers
Fall 1997
(To be completed on November 5/6)
Objective: To understand pointers and linked lists.
You are to write an interactive program that creates a linked list of data. The program should interact with the user so that the user can insert new items into the list, find a record in the list, and delete items from the list.
Your program must be modular. Each separate function described above (and perhaps others, as you see fit) should be implemented in a separate procedure, which the main program calls. Marks will be deducted for lack of good modular style.
The linked list will contain the following items:
Your main program should create an empty list, ready for insertions. It should then prompt the user for a command, which can be one of five things:
Here is a sample interactive session:
Linked List Maintainer of Name, Age and Career List has been initialized. Commands are I (insert), F (find), D (delete), L (list), Q (quit) Command? I name: Chretien age: 62 career: ballet dancer Inserted. Command? I name: Manning age: 63 career: Concert Pianist Inserted. Command? I name: Charest age: 39 career: Prime Minister Inserted. Command? F name: Manning Manning is 63 years old and wants to be a Concert Pianist Command? D name: Charest Charest deleted. Command? D name: Gump Gump is not in the linked list. Command? L Manning is 63 years old and wants to be a Concert Pianist Chretien is 62 years old and wants to be a ballet dancer Command? Q Goodbye
You should use a separate procedure for each of the different commands given above.
Make the program above maintain the list in sorted alphabetical order by the person's last name. Thus the insertion routine would have to insert any new item in the correct order.