Description of Program You are to write a program name phonedir that maintains a
ID: 3593348 • Letter: D
Question
Description of Program
You are to write a program name phonedir that maintains a list of records containing names and phone numbers. The program will prompt the user for a command, execute the command, then prompt the user for another command. (
The list must be kept sorted at all times – based on last name. Sorting is to be achieved when an insertion or modification is done. NO SORTING ROUTINE IS ALLOWED. ALWAYS INSERT A NEW RECORD OR EDITED RECORD INTO ITS' CORRECT PLACE IN THE LIST. Note: Changing the last name will require resorting.
Use as many generic algorithm as you can.)
The commands must be chosen from the following possibilities:
a Show all records
d Delete the current record
f Change the first name in the current record
l Change the last name in the current record
n Add a new record
p Change the phone number in the current record
q Quit
s Select a record from the record list to become the current record
The following example illustrates the behavior of each command (user input is in bold)
c:phonedir [enter]
A Program to keep a Phone Directory:
a Show all records
d Delete the current record
f Change the first name in the current record
l Change the last name in the current record
n Add a new record
p Change the phone number in the current record
q Quit
s Select a record from the record list to become the current record
Enter a command from the list above (q to quit): f
No current record
a Show all records
d Delete the current record
f Change the first name in the current record
l Change the last name in the current record
n Add a new record
p Change the phone number in the current record
q Quit
s Select a record from the record list to become the current record
Enter a command from the list above (q to quit): n
Enter first name: Barry
Enter last name: Drake
Enter phone number: 770-591-8071
Current record is: Barry Drake 770-591-8071
a Show all records
d Delete the current record
f Change the first name in the current record
l Change the last name in the current record
n Add a new record
p Change the phone number in the current record
q Quit
s Select a record from the record list to become the current record
Enter a command from the list above (q to quit): n
Enter first name: Ada
Enter last name: Caswell
Enter phone number: 770-251-3456
Current record is: Ada Caswell 770-251-3456
MENU DISPLAYED AGAIN
Enter a command from the list above (q to quit): a
First Name Last Name Phone Number
------------- ------------- ------------------
Ada Caswell 770-251-3456
Barry Drake 770-591-8071
MENU DISPLAYED AGAIN
Enter a command from the list above (q to quit): n
Enter first name: Elwood
Enter last name: Havens
Enter phone number: 404-345-8897
<>Current record is: Elwood Havens 404-345-8897
MENU DISPLAYED AGAIN
Enter a command from the list above (q to quit): a
First Name Last Name Phone Number
------------- ------------- ------------------
Ada Caswell 770-251-3456
Barry Drake 770-591-8071
Elwood Havens 404-345-8897
MENU DISPLAYED AGAIN<>
Enter a command from the list above (q to quit): f
Enter new first name: Jake
Current record is: Jake Havens 404-345-8897
MENU DISPLAYED AGAIN
Enter a command from the list above (q to quit): s
Enter first name: Carl
Enter last name: Patton
No matching record found.
MENU DISPLAYED AGAIN
Enter a command from the list above (q to quit): s
Enter first name: Barry
Enter last name: Drake
<> Current record is: Barry Drake 770-591-8071
MENU DISPLAYED AGAIN
Enter a command from the list above (q to quit): d
Deleted: Barry Drake 770-591-8071
MENU DISPLAYED AGAIN
Enter a command from the list above (q to quit): a
First Name Last Name Phone Number
------------- ------------- ------------------
Ada Caswell 770-251-3456
Elwood Havens 404-345-8897
MENU DISPLAYED AGAIN
Enter a command from the list above (q to quit): z
Illegal command
Enter a command from the list above (q to quit): q
The output of your program must match the format illustrated in this example.
Here are some other additional requirements for this program:
You may assume that phone number contains no spaces.
After a deletion, there is no record currently selected
Each record (first name, last name and phone number) must be stored as an object. These objects must be stored in a Linked List.
The list must be kept sorted at all times – based on last name. Sorting is to be achieved when an insertion or modification is done. NO SORTING ROUTINE IS ALLOWED. ALWAYS INSERT A NEW RECORD OR EDITED RECORD INTO ITS' CORRECT PLACE IN THE LIST. Note: Changing the last name will require resorting.
Use as many generic algorithm as you can.