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

  Write a program which read in information for multiple books

Write and implement a C++ class which represents a Book, and use this class in a main program which reads in information for multiple books from a data file.

  Write procedure sort that swaps its three inputs

Write a procedure sort3(int& a, int& b, int& c) that swaps its three inputs to arrange them in sorted order. Without actually compiling and running a program, determine the results of the given function calls.

  Design a class named pet

Design a class named Pet, which should have the following fields: Name - The name field holds the name of a pet. and Type - The type field holds the type of animal that is the pet. Example values are "Dog", "Cat", and "Bird"

  Application shows a user friendly message

The software fails to respond to user inputs, if there is a connectivity problem with the database. Add the code snippet that the development team should use to ensure that the application shows a user- friendly message, if such a situation arises..

  Output various methods of passing structure variables

Can someone please explain with examples of source code and output various methods of passing structure variables as arguments to functions in C++.

  Principles of programming with c++

Name The players name, formatted as I.s where I is the initial of the player's first name and s is the player's surname.

  Create a simple text editor that has one large rich text box

Complete the following programming exercise (SIMPLE TEXT EDITOR WITH ONE LARGE RICH TEXT BOX). You will use the OpenFileDialog, StreamReader and StreamWriter objects; the Close, Peek, ReadLine, ShowDialog and WriteLine methods.

  Write a c program that creates a union named users

Write a C program that creates a union named "users" with two members (last name and email).

  Determine the goos pay for each of several employees

Develop a C++ program that uses a while statement to determine the goos pay for each of several employees.

  Statement that best describes bayesian reasoning

what is the equation of that separates the two classes - Select the statement that best describes BAYESIAN reasoning

  Class mail order

Set up one one-dimensional array for each field: product number (integer), unit price (double), and current inventory level (integer) in main memory to hold the above product information. There should be five rows (0 to 4) in each array, one for e..

  Program to compute gross wages for employee using array

Write program which uses the following arrays: payRate: array of seven floats to hold each employee's hourly pay rate. wages: array of seven floats to hold each employee's gross wages.

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