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

In C++, I am being asked to create and maintain a list of contact information fo

ID: 3574651 • Letter: I

Question

In C++, I am being asked to create and maintain a list of contact information for your friends and family. Include the following functionality:

1) add a new contact

2) delete a contact

3) update contact info

4) display contacts in ascending order by last name

5) find the contact info for a particular person

For each person you should store name, phone number, and email address.

You must chose an appropriate data structure to use to implement this system, and design and implement a contactType class.

Explanation / Answer

#include <cstdlib>     /* srand, rand */
#include <ctime>
#include <unistd.h>
#include <cstdio>
#include <csignal>
using namespace std;

class contactType
{
public:
    string firstname,lastname,emailid;
    int phno;
    contactType(string fname,string lname, string emid,int pno)
    {
    firstname=fname;
    lastname =lname;
    emailid =emid;
    phno= pno;
}
}
class contactlist
{
public:
contactType* head;
contactlist()
{
  head=null;
}
void add(contactType * newnode)
{
  if(head==null)
  {
   head=newnode;
   head->next= null;
  }
  else
  {
   contactType* ptr =head;
   while(ptr->next)
   {
    ptr=ptr->next;
   }
   ptr->next =newnode;
   newnode->next =null;
  }
}
void delete(contactType * newnode)
{
  if(head==null)
  {
   return ;
  }
  else if(head->next ==null)
  {
   return null;
  }
  else
  {
   contactType* ptr =head;
   while(ptr->next != newnode)
   {
    ptr=ptr->next;
   }
   contactType *temp =newnode;
   ptr->next =newnode->next;
   delete newnode;
  }
}
void showcontactinfo(contactType* newnode)
{
  if(head==null)
  {
   return ;
  }
  else
  {
   contactType* ptr =head;
   while(ptr != newnode)
   {
    ptr=ptr->next;
   }
   cout<<"firstname is :"<<ptr->firstname;
       cout<<"lastname is :"<<ptr->lastname;
         cout<<"phone no is :"<<ptr->phno;
          cout<<"email id is :"<<ptr->emailid;
  }
}
}
int main()
{
return 0;
}