Question

Design an online contact list to keep track of names and phone numbers.

a. Define a class contactList that can store a name and up to 3 phone numbers (use an array for the phone numbers). Use constructors to automatically initialize the member variables.
b. Add the following operations to your program:
i. Add a new contact. Ask the user to enter the name and up to 3 phone numbers.
ii. Delete a contact by having the user enter the name.
iii. Search the list by name and print the name and phone numbers for that one person.
iv. Print all contacts and phone numbers for each contact.
c. Create a program to test your class. The program should have a menu with options:
1. Add a contact
2. Delete a contact
3. Print all contacts
4. Search for a contact
5. Exit

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

// contactlist.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <string>

using namespace std;

class contactList
{
public:
string name;
string phoneNumber[3];
contactList(string n, string pn0, string pn1, string pn2)
{
name = n;
phoneNumber[0] = pn0;
phoneNumber[1] = pn1;
phoneNumber[2] = pn2;
next = NULL;
}
contactList* next;
};

bool SearchContactList(contactList* head, string name) // Returns boolean as it is used to check if the new contact alreadz exist
{
contactList* contact;
int i = 1;
bool found = false;
contact = head;
while ((contact != NULL) && (contact->name != name))
{
contact = contact->next;
i++;
}
if (contact != NULL)
{
cout << endl;
cout << "Contact found:" << endl;
cout << i << ". Name: " << contact->name << endl;
cout << i << ". Phone number 1: " << contact->phoneNumber[0] << endl;
cout << i << ". Phone number 2: " << contact->phoneNumber[1] << endl;
cout << i << ". Phone number 3: " << contact->phoneNumber[2] << endl;
cout << endl;
found = true;
}
return found;
}...

This is only a preview of the solution. Please use the purchase button to see the entire solution

Assisting Tutor

Related Homework Solutions

Temperature Program Using C++
Homework Solution
$20.00
Computer Science
Programming
C++
Range
Coding
Variables
Trip
File Management
Input
Output
Statistics
Freezing Days
Average Values
Integers
Statements
Extreme Values
Matrix Multiplication
Homework Solution
$23.00
Matrix
Multiplication
Computer
Science
C-Family
Programming
Print
Results
Input
Output
Values
Label
C++ Problem: Integers Divisible By 3
Homework Solution
$10.00
Programming
C++
Computer Science
Integers
Division
Input
Output
Loops
Conditions
Mathematics
Modulus Operator
Programming Questions
Homework Solution
$40.00
Programming
C++
Computer Science
Strings
Codes
Characters
Pointers
Buffer
Human-Readable Information
CMYK Colors
Encoding
Issues
Compiler Errors
Assembly Language
Intel Machine
Lines
Symbols
Get help from a qualified tutor
Live Chats