Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask C/C++ Expert


Home >> C/C++

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). 

C/C++, Programming

  • Category:- C/C++
  • Reference No.:- M9641851

Have any Question?


Related Questions in C/C++

Software development fundamentals assignment 1 -details amp

Software Development Fundamentals Assignment 1 - Details & Problems - In this assignment, you are required to answer the short questions, identify error in the code, give output of the code and develop three C# Console P ...

Assignment word matchingwhats a six-letter word that has an

Assignment: Word Matching What's a six-letter word that has an e as its first, third, and fifth letter? Can you find an anagram of pine grave. Or how about a word that starts and ends with ant (other than ant itself, of ...

1 implement the binary search tree bst in c using the node

1. Implement the Binary Search Tree (BST) in C++, using the Node class template provided below. Please read the provided helper methods in class BST, especially for deleteValue(), make sure you get a fully understanding ...

Project - space race part a console Project - Space Race Part A: Console Implementation

Project - Space Race Part A: Console Implementation INTRODUCTION This assignment aims to give you a real problem-solving experience, similar to what you might encounter in the workplace. You have been hired to complete a ...

There are several ways to calculate the pulse width of a

There are several ways to calculate the pulse width of a digital input signal. One method is to directly read the input pin and another method (more efficient) is to use a timer and pin change interrupt. Function startTi ...

Why do researcher drop the ewaste and where does it end

Why do researcher drop the ewaste and where does it end up?

What are the legal requirements with which websites must

What are the legal requirements with which websites must comply in order to meet the needs of persons with disabilities? Why is maximizing accessibility important to everyone?

Question 1find the minimum and maximum of a list of numbers

Question: 1. Find the Minimum and Maximum of a List of Numbers: 10 points File: find_min_max.cpp Write a program that reads some number of integers from the user and finds the minimum and maximum numbers in this list. Th ...

Assign ment - genetic algorithmin this assignment you will

ASSIGN MENT - GENETIC ALGORITHM In this assignment, you will use your C programming skills to build a simple Genetic Algorithm. DESCRIPTION OF THE PROGRAM - CORE REQUIREMENTS - REQ1: Command-line arguments The user of yo ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As