Building a contact system

Assignment Help C/C++ Programming
Reference no: EM132395657

Contacts

Assignment 1

The two (2) assignments this semester will revolve around building a Contact system that is searchable and efficient.

In the first assignment, you will build a Contact structure that contains other structures representing the contact Name, Address and phone Numbers.

Milestone 1
Download or clone Assignment 1
Open the project file for MS1 and look inside. You will find a file named contacts.h. The .h extension identifies this file as a header file. Header files contain declarations of structs and function prototypes. In this header file, the struct Name is already declared.
Structure Name has three (3) members: firstName, a C string that can hold up to 30 characters middleInitial, a C string that can hold up to 6 characters, and lastName, a C string that can hold up to 35 characters.
struct Name
{
char firstName[31]; char middleInitial[7]; char lastName[36];
};


Declare two (2) more structures named Address, and Numbers, in the header file, contacts.h
Structure Address has five (5) members: streetNumber, street, apartmentNumber, postalCode, and
city.
streetNumber: int, (logic for this field should enforce values greater than 0) street: C string, up to 40 characters
apartmentNumber: int, (logic for this field should enforce values greater than 0) postalCode: C string, up to 7 characters
city: C string, up to 40 characters
Structure Numbers has three (3) members: cell, home, and business. These are all C strings that can hold up to 10 characters.

Milestone 2
Application Logic

Open the project file for MS2 and look inside. You will find a source file named a1ms2.c. Use this file and in it code the main() function by implementing the following. Make sure that your project contains the contacts.h header file from milestone 1:
• Declare a variable of type Name (use a self-describing variable name) to be used for storing a
contact's full name
- Initialize each member to an empty C string
• Declare a variable of type Address (use a self-describing variable name) to be used for storing a contact's address information
- Initialize the members so numeric values are set to zero and char arrays are set to an empty C string
• Declare a variable of type Numbers (use a self-describing variable name) to be used for storing a
contact's phone(s) information
- Initialize each member to an empty C string
• Display to the screen a welcome message:
>Contact Management System<

Contact Name

• Prompt the user to enter the required member data for the Name type. First, ask for the first name:

>Please enter the contact's first name: <
- Read and store the C string value the user enters into the appropriate Name member

• Prompt the user if a middle initial(s) value needs to be entered (see figure: 1.2.1 above regarding optional values for example prompt)
- Evaluate the entered value; if an ‘n' is entered proceed with the next member entry otherwise
prompt for the middle initial(s):
- >Please enter the contact's middle initial(s): <
- Read and store the C string value the user enters into the appropriate Name member

• Prompt the user to enter the last name:
>Please enter the contact's last name: <
- Read and store the C string value the user enters into the appropriate Name member

Contact Address

• Prompt the user to enter the required member data for the Address type. First, ask for the street number:
>Please enter the contact's street number: <
- Read and store the number entered by the user into the appropriate Address member
- Hint: Review the specifications for this structure member's valid values

• Prompt the user to enter the street name:
>Please enter the contact's street name: <
- Read and store the C string value the user enters into the appropriate Address member

• Prompt the user if an apartment number needs to be entered (see figure: 1.2.1 above regarding optional values for example prompt)
- Evaluate the entered value; if an ‘n' is entered proceed with the next member entry otherwise
prompt for the apartment number:
- >Please enter the contact's apartment number: <
- Read and store the number entered by the user into the appropriate Address member
- Hint: Review the specifications for this structure member's valid values

• Prompt the user to enter the postal code:
>Please enter the contact's postal code: <
- Read and store the C string value the user enters into the appropriate Address member

• Prompt the user to enter the city:
>Please enter the contact's city: <
- Read and store the C string value the user enters into the appropriate Address member

Contact Numbers

• Prompt the user to enter the required member data for the Numbers type. First, prompt the user if a cell phone number needs to be entered (see figure: 1.2.1 above regarding optional values for example prompt)
- Evaluate the entered value; if an ‘n' is entered proceed with the next member entry otherwise
prompt for the cell phone number:
- >Please enter the contact's cell phone number: <
- Read and store the number entered by the user into the appropriate Numbers member

• Prompt the user if a home phone number needs to be entered (see figure: 1.2.1 above regarding optional values for example prompt)
- Evaluate the entered value; if an ‘n' is entered proceed with the next member entry otherwise prompt for the home phone number:
- >Please enter the contact's home phone number: <
- Read and store the number entered by the user into the appropriate Numbers member


• Prompt the user if a business phone number needs to be entered (see figure: 1.2.1 above regarding optional values for example prompt)
- Evaluate the entered value; if an ‘n' is entered don't prompt for this value otherwise prompt for
the business phone number:
- >Please enter the contact's business phone number: <
- Read and store the number entered by the user into the appropriate Numbers member
Test the above logic and your 3 structures by referring to the below sample output (input's are
identified in RED). Your output should match exactly:

Milestone 2 Reflection

Please provide answers to the following in a text file named reflect.txt.

In three or more paragraphs and a minimum of 150 words, explain what you learned while doing these first two milestones. In addition to what you learned, your reflection should also include the following:

• Can you think of a more efficient way to ask a user to add the required information to each data field? Justify your thoughts with an example.
• Discuss the differences between a C string and a primitive character array. What would happen if you attempt to display the contents of a primitive character array (not a C string) using the printf specifier "%s"?

Milestone 3

A struct is a data type that contains data members, as you have seen in MS1 and MS2. Up to now the members of our structs have always been comprised of the primitive data types that are part of the C language (int, float, double, char, and arrays of these types). The C language defines a data member as a member of any type, other than its own type. So, this means that a struct can contain not only the primitive types but also any type that we ourselves create.

Open the project file for MS3 and look inside. Modify the contacts.h header file to include your work from MS2 and declare another struct named Contact. Contact has three (3) data members, user-defined types Name, Address and Numbers. The Name type member should be called "name", the Address type member should be called "address", and the Numbers member should be called "numbers".

Milestone 4

The focus of this milestone is to change the data input process to use functions.
Open the project file for MS4 and look inside. Review the contacts.h file and copy the contents from your work in MS3 where the comments indicate.

Define the following function prototypes in contacts.h


NOTE:

Only code the prototypes - NOT the full definitions in this file. For additional help on defining functions and function prototypes please refer to the file functionsAndHeaderFiles.pdf in this milestone directory.

Below is a list of the function prototypes with a full description of what each function should do.
void getName(struct Name *name) - Receives a pointer to a Name and performs the actions described below.
• Prompt the user to enter the required member data for the Name type. First, ask for the first name:

>Please enter the contact's first name: <
- Read and store the C string value the user enters into the appropriate Name member

• Prompt the user if a middle initial(s) value needs to be entered (see figure: 1.2.1 in milestone 2 above regarding optional values for example prompt)
- Evaluate the entered value; if an ‘n' is entered proceed with the next member entry otherwise
prompt for the middle initial(s):
- >Please enter the contact's middle initial(s): <
- Read and store the C string value the user enters into the appropriate Name member

• Prompt the user to enter the last name:
>Please enter the contact's last name: <
- Read and store the C string value the user enters into the appropriate Name member

void getAddress(struct Address *address) - Receives a pointer to an Address and performs the actions described below.
• Prompt the user to enter the required member data for the Address type. First, ask for the street number:
>Please enter the contact's street number: <
- Read and store the number entered by the user into the appropriate Address member
- Hint: Review the specifications for this structure member's valid values

• Prompt the user to enter the street name:
>Please enter the contact's street name: <
- Read and store the C string value the user enters into the appropriate Address member
• Prompt the user if an apartment number needs to be entered (see figure: 1.2.1 in milestone 2 regarding optional values for example prompt)
- Evaluate the entered value; if an ‘n' is entered proceed with the next member entry otherwise
prompt for the apartment number:
- >Please enter the contact's apartment number: <
- Read and store the number entered by the user into the appropriate Address member
- Hint: Review the specifications for this structure member's valid values

• Prompt the user to enter the postal code:
>Please enter the contact's postal code: <
- Read and store the C string value the user enters into the appropriate Address member

• Prompt the user to enter the city:
>Please enter the contact's city: <
- Read and store the C string value the user enters into the appropriate Address member

void getNumbers(struct Numbers *numbers) - Receives a pointer to a Numbers and performs the actions described below.

• Prompt the user to enter the required member data for the Numbers type. First, prompt the user if a cell phone number needs to be entered (see figure: 1.2.1 in milestone 2 above regarding optional values for example prompt)
- Evaluate the entered value; if an ‘n' is entered proceed with the next member entry otherwise
prompt for the cell phone number:
- >Please enter the contact's cell phone number: <
- Read and store the number entered by the user into the appropriate Numbers member

• Prompt the user if a home phone number needs to be entered (see figure: 1.2.1 in milestone 2 above regarding optional values for example prompt)
- Evaluate the entered value; if an ‘n' is entered proceed with the next member entry otherwise
prompt for the home phone number:
- >Please enter the contact's home phone number: <
- Read and store the number entered by the user into the appropriate Numbers member

• Prompt the user if a business phone number needs to be entered (see figure: 1.2.1 in milestone 2 above regarding optional values for example prompt)
- Evaluate the entered value; if an ‘n' is entered don't prompt for this value otherwise prompt for
the business phone number:
- >Please enter the contact's business phone number: <
- Read and store the number entered by the user into the appropriate Numbers member

Open the file contacts.c and define the full function definitions (where the comments instruct). Hint: The logic for these functions are already done from MS2 found in file a1ms2.c

Milestone 4 Reflection
Please provide answers to the following in a text file named reflect.txt.

In three or more paragraphs and a minimum of 150 words, explain what you learned from doing milestones three and four. In addition to what you learned, your reflection should also include the following:

• An explanation of why you think this assignment has asked you to code a struct, Contact, that holds three other structs as data members.
• An explanation why it would be poor design to pass a pointer to type Contact as an argument in the functions getName, getAddress, and getNumbers.

Attachment:- Contacts.rar

Reference no: EM132395657

Questions Cloud

Review the abstract and the methods section of the article : To assist in your search, remove the words qualitative and quantitative and include words that narrow or broaden your main topic.
Develop strategies for improving leadership skills : Develop strategies for improving leadership skills. Why is it necessary to have someone acting in the role of project manager?
How as the nurse would you care for the given patient : As the nurse you are caring for a patient with a Stage 2 wound on their coccyx. How as the nurse would you care for this patient? (Include a description of the)
BUSI12195 Principles of Marketing Assignment : BUSI12195 Principles of Marketing Assignment Help and Solution, Nottingham Trent University, UK. Develop a marketing mix strategy for the launch of new business
Building a contact system : Revolve around building a Contact system that is searchable and efficient - build a Contact structure that contains other structures representing the contact
Have you ever worked in a healthcare facility : Have you ever worked in a healthcare facility that had Magnet accreditation, or had experience with shared governance? If so, share your experience.
How provider productivity is calculated in clinical setting : Reflect on the current roles of advanced practice nurses in healthcare as the care providers at the front line of disease management and health promotion.
Identify and explain the key components of a project plan : Identify and explain the key components of a project plan. Define and explain key components of Work Breakdown Structure (WBS).
How as the nurse would you care for such a patient : If the nurse is caring for a patient with stage two wound on their coccyx. How as the nurse would you care for such a patient? (pls include a description).

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd