1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
#include <iostream>
#include <string>
using namespace std;
void newEntry();
struct AddressBook
{
string firstName;
string lastName;
string streetAddress;
string city;
string state;
string zipCode;
string phone;
};
void menu()
{
int choice = 0;
cout << "******Your Address Book******" << endl << endl;
cout << "Menu:" << endl;
cout << "1) New Entry" << endl;
cout << "2) Display All Entries" << endl;
cout << "3) Display Entries Starting with a Certain Letter" << endl;
cout << "4) Exit" << endl << endl;
cin >> choice;
while (choice > 4 || choice < 1)
{
cout << "I'm sorry. That is an invalid choice. Please try again." << endl << endl;
cout << "******Your Address Book******" << endl << endl;
cout << "Menu:" << endl;
cout << "1) New Entry" << endl;
cout << "2) Display All Entries" << endl;
cout << "3) Display Entries Starting with a Certain Letter" << endl;
cout << "4) Exit" << endl << endl;
cin >> choice;
}
if (choice == 1) {
newEntry();
}
}
void newEntry()
{
AddressBook contact;
cout << "Please enter the following information for your new contact:" << endl;
cout << "First Name: " << endl;
getline(cin, contact.firstName, '\n');
cout << "Last Name: " << endl;
getline(cin, contact.lastName, '\n');
cout << "Street Address: " << endl;
getline(cin, contact.streetAddress, '\n');
cout << "City: " << endl;
getline(cin, contact.city, '\n');
cout << "State: " << endl;
getline(cin, contact.state, '\n');
cout << "Zip Code: " << endl;
getline(cin, contact.zipCode, '\n');
cout << "Phone Number: " << endl;
getline(cin, contact.phone, '\n');
}
int main()
{
menu();
}
|