CIS 15/615 INSTRUCTOR: RAVE HARPAZ
ASSIGNMENT # 3
Your assignment is to upgrade/improve your phonebook database by adding and modifying existing functions according to the new topics we have covered in class.
Program
guidelines:
·
Your database will now exist in a text file called “pbook.dat”
,
You will have to read and
write to this file. I strongly advise having one record per line, where each
line contains the record’s appropriate fields, each separated by a blank space.
·
Add a function called Init()
which will be the first function executed. This function will initialize global
variables, load the database from your data file into the Phone_Book
(array) and set a record counter.
Use the method we covered in to read a text file.
·
Add a menu function using the switch command. Your menu should
include the following operations:
1 - add
record - one at a time, i.e. upon termination of the add_record
function, the user should be returned to the main menu. This should enable the
user to enter new records or choose other options.
2 - search
record – use the recursive binary search algorithm covered in class. The
function should output the search results in a nice aligned manner with an
appropriate heading.
3 - print
phonebook – this function should already exist from the previous
assignment. You will only need to add it to the menu
options, but make sure that the output will be nicely aligned with appropriate
headings.
3 - quit
program – terminate the program.
·
After adding a new record to the database, the add_record
function should sort the database. Sorting the database will ensure that binary
search will work correctly. Use quick sort to
sort the database.
·
Before terminating the program (using the quit option) the
database should be saved to your data file (pbook.dat).
This will ensure that new records added to the database will be saved for
future use.
· You should test all functions using at least 10 records.
· Use pointer notation only (except for the declaration of Phone_Book).
· Do not forget to comment your program.
Good luck !