Do Practice Program except change the program to use vectors of strings instead of arrays of strings.
Program
The following code creates a small phone book. An array is used to store a list of names and another array is used to store the phone numbers that go with each name. For example, Michael Myers’ phone number is 333-8000 and Ash Williams’ phone number is 333-2323. Write the function lookupName so the code properly looks up and returns the phone number for the input target name.
int main(){ using namespace std; string names[] = {"Michael Myers", "Ash Williams", "Jack Torrance", "Freddy Krueger"}; string phoneNumbers[] = {"333-8000","333-2323", "333-6150","339-7970"}; string targetName, targetPhone; char c; do { cout << "Enter a name to find the " << "corresponding phone number." << endl; getline(cin, targetName); targetPhone = lookupName(targetName, names, phoneNumbers,4); if (targetPhone.length() > 0) cout << "The number is: " << targetPhone < endl; else cout << "Name not found. " << endl; cout << "Look up another name? (y/n)" < endl; cin >> c; cin.ignore();} while (c == 'y');return 0;}
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.