Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You will be making a digital rolodex using a doubly linked list. Your program wi

ID: 3587631 • Letter: Y

Question

You will be making a digital rolodex using a doubly linked list. Your program will have the following criteria:

1. Each node in the list will contain the following information about the person:

1. First Name

2. Last Name

3. Address

4. Phone Number

5. Email Address

6. twitter handle.

2. When the program opens it will read contact information from a text file and create a doubly linked list with the information.

3. The user will be able to:

search for and display specific user by any piece of information. Exact matches only is fine. Should be able to navigate through a list if there are multiple results. thus, you probably want to sort first.

add a contact to the rolodex

delete a user from the rolodex

sort the rolodex by any piece of information and navigate through it, displaying one contact at a time. (they will need to be able to exit this navigation mode)

quit the program.

4. Upon quitting, all contact information should be written back to the text file.

The program should be in C++

Explanation / Answer

#include<iostream>
#include<fstream>
#include<sstream>
#include<stdlib.h>

using namespace std;

struct roolex{
string first_name;
string last_name;
string address;
long int phone_no;
string email_addr;
string twitter_hndl;
roolex *prev;
roolex *next;
};

struct roolex *head=NULL, *ptr;

void insertt(string fn, string ln, string ad, long int ph, string emad, string twh){

struct roolex *curr = new struct roolex;

curr->first_name = fn;
curr->last_name = ln;
curr->address = ad;
curr->phone_no = ph;
curr->email_addr = emad;
curr->twitter_hndl = twh;
curr->next = NULL;

if(head == NULL){
head = curr;
}
else{
ptr->next = curr;
curr->prev = ptr;
}
ptr = curr;
}

void searchh(string info_type){

string ser;
long int pser;
struct roolex *temp;
temp = head;
int flag = 0;

if(info_type == "firstname"){
cout<<"Enter user firstname to search:-";
cin>>ser;
cout<<" Your searching for:- ";
while(temp->next!=NULL){
if(temp->first_name == ser){
cout<<temp->first_name<<" "<<temp->last_name<<" "<<temp->address<<" "<<temp->phone_no<<" "<<temp->email_addr<<" "<<temp->twitter_hndl<<endl;
flag = 1;
break;
}
temp->next = temp;
}
if(flag == 0)
cout<<"Not in the list...";
}
if(info_type == "lastname"){
cout<<"Enter user lastname to search:-";
cin>>ser;
cout<<" Your searching for:- ";

while(temp!=NULL){
if(temp->last_name == ser){
cout<<temp->first_name<<" "<<temp->last_name<<" "<<temp->address<<" "<<temp->phone_no<<" "<<temp->email_addr<<" "<<temp->twitter_hndl<<endl;
flag = 1;
break;
}
temp = temp->next;
}
if(flag == 0)
cout<<"Not in the list...";
}
if(info_type == "address"){
cout<<"Enter user address to search:-";
cin>>ser;
cout<<" Your searching for:- ";

while(temp!=NULL){
if(temp->address == ser){
cout<<temp->first_name<<" "<<temp->last_name<<" "<<temp->address<<" "<<temp->phone_no<<" "<<temp->email_addr<<" "<<temp->twitter_hndl<<endl;
flag = 1;
break;
}
temp = temp->next;
}
if(flag == 0)
cout<<"Not in the list...";
}
if(info_type == "phone_no"){
cout<<"Enter user phone no. to search:-";
cin>>pser;
cout<<" Your searching for:- ";

while(temp!=NULL){
if(temp->phone_no == pser){
cout<<temp->first_name<<" "<<temp->last_name<<" "<<temp->address<<" "<<temp->phone_no<<" "<<temp->email_addr<<" "<<temp->twitter_hndl<<endl;
flag = 1;
break;
}
temp = temp->next;
}
if(flag == 0)
cout<<"Not in the list...";
}
if(info_type == "email"){
cout<<"Enter user email address to search:-";
cin>>ser;
cout<<" Your searching for:- ";

while(temp!=NULL){
if(temp->email_addr == ser){
cout<<temp->first_name<<" "<<temp->last_name<<" "<<temp->address<<" "<<temp->phone_no<<" "<<temp->email_addr<<" "<<temp->twitter_hndl<<endl;
flag = 1;
break;
}
temp = temp->next;
}
if(flag == 0)
cout<<"Not in the list...";
}
if(info_type == "twitter"){
cout<<"Enter user twitter handle to search:-";
cin>>ser;
cout<<" Your searching for:- ";

while(temp!=NULL){
if(temp->twitter_hndl == ser){
cout<<temp->first_name<<" "<<temp->last_name<<" "<<temp->address<<" "<<temp->phone_no<<" "<<temp->email_addr<<" "<<temp->twitter_hndl<<endl;
flag = 1;
break;
}
temp = temp->next;
}
if(flag == 0)
cout<<"Not in the list...";
}
}

void deletee(string del){

struct roolex *temp, *pre;
temp = head;

while(temp!=NULL){

if(temp->first_name == del){
pre->next = temp->next;
temp->next->prev = pre;
}
pre = temp;
temp = temp->next;
}
free(temp);

}
int main(){

int i = 0, c=0;
string file = "roolex.txt", data;

ifstream in,inn;
ofstream ff;
in.open(file.c_str());

while(getline(in, data))
c++;
string *f_n = new string[c];
string *l_n = new string[c];
string *ad_d = new string[c];
long int *p_n = new long int[c];
string *e_m = new string[c];
string *t_h = new string[c];

inn.open(file.c_str());

string f, l, add, eml, th;
long int p;

while(getline(inn, data)){
istringstream ss(data);

ss>>f>>l>>add>>p>>eml>>th;
f_n[i] = f;
l_n[i] = l;
ad_d[i] = add;
p_n[i] = p;
e_m[i] = eml;
t_h[i] = th;
i++;
}
for(i=0;i<c;i++)
insertt(f_n[i], l_n[i], ad_d[i], p_n[i], e_m[i], t_h[i]);

struct roolex *temp;
temp = head;
/* cout<<temp->first_name<<" "<<temp->last_name<<" "<<temp->address<<" "<<temp->phone_no<<" "<<temp->email_addr<<" "<<temp->twitter_hndl<<endl;
temp = temp->next;
}*/

int ch;
string str;
long int li;
while(1){


cout<<" 1.Search by information ";
cout<<"2.Add contact ";
cout<<"3.Delete any record ";
cout<<"5.Exit the program ";
cout<<"Enter your choice ";
cin>>ch;

switch(ch){

case 1: cout<<" Enter name by which you want to search:- ";
cout<<" firstname ";
cout<<" lastname ";
cout<<" address ";
cout<<" phone_no ";
cout<<" email ";
cout<<" twitter ";
cout<<" Please enter same as given ";
cin>>str;
searchh(str);
break;

case 2: cout<<"Enter first name:-";
cin>> f;
cout<<"Enter last name:-";
cin>> l;
cout<<"Enter address:-";
cin>> add;
cout<<"Enter phone no.:-";
cin>> p;
cout<<"Enter email:-";
cin>> eml;
cout<<"Enter twitter handle:-";
cin>> th;
insertt(f, l, add, p, eml, th);
break;
case 3: cout<<" Enter firstname to delete :- ";
cin>>f;
deletee(f);
break;
case 4: ff.open(file.c_str());
temp = head;
while(temp!=NULL){
ff<<temp->first_name<<" "<<temp->last_name<<" "<<temp->address<<" "<<temp->phone_no<<" "<<temp->email_addr<<" "<<temp->twitter_hndl<<endl;
temp = temp->next;
}
ff.close();
exit(0);
break;
default: cout<<"Invalid choice... ";

}

}

//create file roolex.txt

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote