Use a sequential text file to store your records


In this assignment you are asked to develop a C program that maintains a sample addressbook system stored in a sequential text file.
Start by designing a contact structure. A contact record describes the first name (char[40]), last name (char[40]), address (char[100]), Postal Code (char[6]) and phone number (char[10]).
Your program should be able to interactively ask the user for input, and support up to MAX (10) records.
Next you should save the records to a sequential text file named "contactlist.dat". In this file you will store all the records in a format that you would be able to read back later when requested and display the contents accordingly. A sample run of the program, with its interactive menu is shown below.

Example:
*** Personal Contact Book v1.0 ***
1. Add new contact
2. Display current contacts
3. Search for a contact
4. Save contacts to file
5. Load contacts from file
6. Exit
> 1

Adding new contact:
First name: John
Last name : Doe
Address : 123 any street
PostalCode: N8N8N8
Phone : 5192533000

Add another contact? y

Adding new contact:
First name: Mary
Last name : Jane
Address : 123 Park street
PostalCode: X8X4X4
Phone : 5192534000
Add another contact? n

1. Add new contact
2. Display current contacts
3. Search for a contact
4. Save contacts to file
5. Load contacts from file
6. Exit
> 4

Contact List saved successfully.

1. Add new contact
2. Display current contacts
3. Search for a contact
4. Save contacts to file
5. Load contacts from file
6. Exit
> 3

What is the contact's last name? jane
Found 1 record(s):
First name: Mary
Last name : Jane
Address : 123 Park street
PostalCode: X8X-4X4
Phone : (519) 253-4000

1. Add new contact
2. Display current contacts
3. Search for a contact
4. Save contacts to file
5. Load contacts from file
6. Exit
> 6
Save your contacts to file before leaving? y
Contact List saved successfully.
Bye!

Additional Rules:

1. Your program interactively requests value from the user. Keep interacting with the user until "exit" is selected from the menu.
2.The phone number is entered in the format aaapppssss where a=area code digit, p=prefix, s=suffix; and when output to the screen it should be displayed in a readable format (aaa) ppp-ssss. Note that in the file it should be stored as originally entered. (example: in: 5192533000 out: (519) 253-3000; consider writing a function to format the phone output and to check a valid phone input (isValidPhoneNumber and FormatPhoneNumber).
Do a similar rule for the postal code to display it in the form N8N-8N8
3. Use the function WordCap() which modifies the first character of the word (or sentence) into upper case and converts the rest of the characters into lower case.
4. Use a simple array to store the records in memory.
5. Use a sequential text file to store your records to file. Note: storing spaces especially in the address field may be problematic when attempting to read the record back. There are many ways around this (research it!), one way is to convert spaces to a special symbol, say underscore '_', right before saving it to file (EncodeSpace), and when reading the encoded_string back from the file we can convert the underscores back to spaces before we display them to the screen (DecodeSpace).
6. Implement a linear search that is capable of searching your entire array based on the last name (case insensitive search). It should display all occurances of records with that last name with the number of records found.
7. Write any functions you feel are necessary and declare any arrays you may need. Document your technique properly.
8. To clarify, when the user is entering data for a new record from the keyboard, you should allow the user to enter spaces such as "123 any street", you then convert the string using EncodeSpace and store the new one (without the spaces/but using underscores) into the file just before writing it.
9. For simplicity, when a file is saved, the contents of the existing files are wiped out and replaced. When a file is loaded, the contents of the array in memory is wiped out and loaded with the new values.
BONUS OPTION 1: ONE bonus mark will be given on this assignment if you extend your program to be able to delete a specific record from the file (search for it first then delete it).
BONUS OPTION 2: ONE bonus mark will be given to have your program sort the array in alphabetical order (by last name then first name) everytime a record is added (ie. insertion sort). 

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Use a sequential text file to store your records
Reference No:- TGS0134273

Expected delivery within 24 Hours