A contact list is a place where you can store a specific contact with other associated information such as a phone number, email address, birthday, etc. Write a program that first takes as input an integer N that represents the number of word pairs in the list to follow. Word pairs consist of a name and a phone number (both strings). That list is followed by a name, and your program should output the phone number associated with that name.
Ex: If the input is:
3 Joe 123-5432 Linda 983-4123 Frank 867-5309 Frank
the output is:
867-5309
Your program must define and call the following function. The
return value of GetPhoneNumber is the phone number associated with
the specific contact name.
string GetPhoneNumber(vector<string> nameVec,
vector<string> phoneNumberVec, string contactName)
Hint: Use two vectors: One for the string names, and the other for the string phone numbers.
6.34.1: LAB: Contact list
#include <iostream>
#include <vector>
using namespace std;
/* Define your function here */
int main() {
/* Type your code here */
return 0;
}
Note: Could you plz go through this code and let me
know if u need any changes in this.Thank You
_________________

________________________
// contacts.txt (input file)
3
Joe 123-5432
Linda 983-4123
Frank 867-5309
__________________________
#include <vector>
#include <fstream>
#include <iostream>
#include <iomanip>
using namespace std;
string GetPhoneNumber(vector<string> nameVec,
vector<string> phoneNumberVec, string contactName);
int main()
{
//Declaring constants which holds input file output
file names
const string INPUTFILE="contacts.txt";
vector<string> names;
vector<string> phones;
string name,phone;
int size;
string line;
// defines an input stream for the data file
ifstream dataIn;
dataIn.open(INPUTFILE.c_str());
// checking whether the file name is valid or not
if (dataIn.fail())
{
cout << "** "<<INPUTFILE<<" Not Found **";
return 1;
}
else
{
dataIn>>size;
//Reading each line from the input file
for(int i=0;i<size;i++)
{
dataIn>>name>>phone;
names.push_back(name);
phones.push_back(phone);
}
dataIn.close();
cout<<"Enter name to search :";
cin>>name;
string res=GetPhoneNumber(names, phones,name);
if(res.compare("none")==0)
{
cout<<"Contact not
found"<<endl;
}
else
{
cout<<res<<endl;
}
}
return 0;
}
string GetPhoneNumber(vector<string> nameVec,
vector<string> phoneNumberVec, string contactName)
{
for(int i=0;i<nameVec.size();i++)
{
if(nameVec[i].compare(contactName)==0)
{
return
phoneNumberVec[i];
}
}
return "none";
}
_____________________________
Output:

_______________Could you plz rate me well.Thank
You
A contact list is a place where you can store a specific contact with other associated...
C++ Please Contact list - functions & parallel arrays/CStrings No Vectors can be used since we haven't learned them yet !! A contact list is a place where you can store a specific information with other associated information such as a phone number, email address, birthday, etc. Write a program that will read 5 data pairs into two parallel arrays. Data pairs consist of a name (as a CString) and a GPA (double). That list is followed by a name,...
Hello I need some help with my CC+ project.
My current project erasing the first two phone numbers and only
printing the 3rd phone number out in the list. Any idea on how to
correct.
Here is the error.
Contacts.h
#ifndef Contact_H
#define Contact_H
#include<string>
using namespace std;
class ContactNode{
public:
ContactNode();
ContactNode(string name, string phone);
void InsertAfter(ContactNode*);
string GetName();
string GetPhoneNumber();
ContactNode* GetNext();
void PrintContactNode();
private:
string contactName;
string contactPhoneNum;
ContactNode* nextNodePtr;
};
#endif
Contacts.cpp
#include <iostream>
#include "Contacts.h"...
In Java.
Write a GUI contact list application. The program should allow you to input names and phone numbers. You should also be able to input a name and have it display the previously entered phone number. The GUI should look something like the following, although you are welcome to format it in any way that works. This should be a GUI application with a JFrame. The program should contain two arrays of Strings. One array will contain a list...
Declare and define TtuStudentNode in TtuStudentNode.h and TtuStudentNode.cpp file. TtuStudentNode has its unique string variable "studentEmail" which contains email address. TtuStudentNode has its unique function member GetEmail() which returns the string variable "studentEmail". TtuStudentNode has its overriding "PrintContactNode()" which has the following definition. void TtuStudentNode::PrintContactNode() { cout << "Name: " << this->contactName << endl; cout << "Phone number: " << this->contactPhoneNum << endl; cout << "Email : " << this->studentEmail << endl; return; } ContactNode.h needs to have the function...
Please help!!
(C++ PROGRAM)
You will 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...
a. Define the struct node that can store a name and up to 3 phone numbers (use an array for the phone numbers). The node struct will also store the address to the next node. b. Define a class contactList that will define a variable to keep track of the number of contacts in the list, a pointer to the first and last node of the list. c. Add the following methods to the class: i. Add a new contact....
20.6 Lab: Contacts You will be building a linked list. Make sure to keep track of both the head and tail nodes (1) Create three files to submit. ContactNode.h-Class declaration ContactNode.cpp- Class definition main.cpp-main0 function (2) Build the ContactNode class per the following specifications Parameterized constructor. Parameters are name followed by phone number Public member functions InsertAfter0 (2 pts) GetName0 -Accessor(1 pt) GetPhoneNumber- Accessor (1 pt) GetNext0-Accessor (1 pt) PrintContactNode Private data members string contactName string contactPhoneNum ContactNode* nextNodePtr Ex....
USING THIS CODE: #include <iostream> #include <string> using namespace std; class Contact { //this class cannot be viewed from outside of the private class. //only the class functions within the class can access private members. private: string name; string email; string phone; //the public class is accessible from anywhere outside of the class //however can only be within the program. public: string getName() const { return name; } void setName(string name) { this->name = name; } string getEmail() const {...
This assignment was locked Mar 24 at 11:59pm. For this lab you will implement a phone book using a linked list to keep people's names and phone numbers organized in alphabetical order. 1. Define a structure to hold the contact information including: name, phone number, a pointer to the next node in the list. Example: struct ContactNode { string name; string phoneNumber; ContactNode *next; } 2. Define a class containing the structure and the appropriate methods to update and retrieve...
//header files #ifndef Contact_H // header files should always have this to avoid #define Contact_H // multiple inclusion in other files #include <string> // this is the only programming assignment which will use this statement. // normally "using namespace std" is looked down upon because it // introduces many common keywords that could be accidentally used, but // it identifies useful types such as string and would normally be used // std::string or std::vector. using namespace std; class Contact...