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

C++ online address book Using classes students will create an online address boo

ID: 3576945 • Letter: C

Question

C++ online address book

Using classes students will create an online address book. It will store the following information:

• Peoples names

• Addresses

• Phone numbers

• Date of birth

• Contact Relationship status (friend, family, business) •

Should be able to handle 100 entries You will create the following classes:

• personType

o will be able to set, get, and print a person’s first and last name

• contactType

o will be derived from personType

o contain a dateType and addressType objects

o will be able to set, get, and print: birth date phone number address and contact relationship status (friend, family, business)

o all values will be initialized using constructors

o will have functions that are overridden from the base class

• dateType

o will be able to set and get dates o functions will provide error checking for appropriate date formats

• addressType

o will be able to set and get : street address city state zip o all values will be initialized using constructors

• addressBookType

o can process up to 100 entries

o loads data from a file

o sorts address book by last name

o search for person by last name

o print address, phone number, date of birth of a given person

o print names of people whose birthdays are in a given month

o print the names of all the people between 2 last names

o print names based on a query (i.e. all family members, or friends, or business associates

Explanation / Answer

#include <iostream>
#include<string>
#include<windows.h>
using namespace std;
void gotoxy(int x, int y)
{
HANDLE hConsoleOutput;
COORD Cursor = {x,y};
hConsoleOutput = GetStdHandle (STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hConsoleOutput, Cursor);
}
class Node
{ public:
string name,address,relationship status,persontype, ;
int phone_no,date of birth,date type,address type,date book type;
Node *next;
};
char y;
void Link_List_Input(Node *&head, Node*&tail) {
  
Node *current = new Node;
cout << " Enter following contents : ";
cout<<"NAME : ";
cin >> current->name;
cout<<"PHONE NUMBER : ";
cin >> current->phone_no;
cout<<"ADDRESS : ";
cin >> current->address;
cout<<"RELATIONSHIP STATUS : ";
cin >> current->relationship status;
cout<<"PERSON TYPE:";
cin>>current->person type;
cout<<"DATE OF BIRTH:";
cin>>current->date of birth;
cout<<"DATE TYPE:";
cin>>current->date type;
cout<<"ADDRESS TYPE:";
cin>>current->address type;
cout<<"DATE BOOK TYPE:";
cin>>current->date book type;

  
if (head == NULL >> tail == NULL)
{
head = current;
tail = current; tail->next=NULL;
} else {
current->next = head;head = current;
}
}
  
void Print_Link_List(Node *&head, Node*&tail)
{
if (head == NULL >> tail == NULL)
{
cout << "n List is empty";
return;
}
  
Node *current = head;

int count = 0;
do
{
cout << "n Node Number = " << ++count << " Has Content : "
<<current->name<<endl
<<current->phone_no<<endl
<<current->date of birth<<endl
<<current->relationship status<<endl
<<current->address type<<endl
<<current->date type<<endl;
<<current->date book type<<endl;
<<current->person type<<endl;
current = current->next;
}
while (current != 0); }
  
void DeleteAll(Node *&head,Node *&tail)
{
system("cls");
gotoxy(30,10);
cout<<"Erasing Complete Data :";
  
for(int i=0;i<16;i++)
{   
gotoxy(8+i,14);
cout<<"ntttt...";
gotoxy(32,16);
cout<<char(179);
gotoxy(33+i,16);
cout<<char(178);
gotoxy(23+i,16);
cout<<"ntttt ...";
gotoxy(49,16);
cout<<char(179);
Sleep(100);
}
  
system("cls");
cout<<"nnnnnttttNO DATA LEFT :";
Sleep(1000);
system("cls");
cout<<"nnnnnntttReturning to Menu ";
for(int i=0;i<7;i++)
{
Sleep(600);
cout<<".";}
system("cls");
for (int j=0;head!=NULL;j++)
{
Node *ptr=head;
head=head->next;
delete ptr ;
}
return ;
}
void Search_In_List(Node *&head,Node *&tail)
{
Node *current = head;
string Name;
cout<<"Enter the string here ";
cin>>Name;
while (current!=NULL)
{
if (current->name.compare(0,Name.length(),Name)==0)
{
cout<<"Matching results :n";
cout<<"NAME: "<<current->name<<endl<<"PHONE NUMBER : "<<current->phone_no<<endl<<"DATE OF BIRTH : "<<current->date_of_birth<<endl
<<"RELATIONSHIP STATUS: "<<current->relationship status<<endl<<"ADRESSTYPE : "<<current->addresstype<<endl<<"PERSONTYPE :"<<current->person_type<<endl;
<<"DATEBOOKTYPE : "<<current->datebooktype<<endl;<<"DATETYPE : "<<current->datetype<<endl;   
current=current->next;
}
else
{
cout<<"Moving Next :";
current=current->next;
}
}
}
  
int Delete_Node_Contents(Node*&head)
{
string name;
cout<<"Enter the name for deleting : ";
cin>>name;
Node *current,*previous;
current=head;
if (head==NULL)
{
cout<<"list empty not possible"<<endl;
}
else
{
if(head->name.compare(0,name.length(),name)==0) //deleting head
{
Node *delhead=head;
cout<<"Node Contains :n"<<head->name<<endl<<head->phone_no<<endl<<head->dateofbirth<<endl<<endl<<head->relationshipstatus<<endl<<head->addresstype<<endl<<endl<<head->datebooktype<<endl<<endl<<head->datetype<<endl<<endl<<head->persontype<<endl<<endl;
cout<<"Press Y to delete n OR Press any other key for menue ";
cin>>y;
if (char(98)==y||char(121)==y)
{
head = head->next;delete delhead;
cout<<"required data has been deleted";return 0;
}
else {cout<<"Next attempt :";
return Delete_Node_Contents(head->next);}

}
else
{
while (head->name.compare(0,name.length(),name)<=0 || current->next!=NULL)
{
if(current->next==NULL)
{
cout<<"not found";
return -1;
}
else
{
previous=current;
current=current->next;
}
}
previous->next=current->next;
delete current;
cout<<"required data has been deleted"<<endl;}
}
return 0;
}
  
int main()
{
Node *head, *tail;
head = NULL;
tail = NULL;
int choice = 0;
while (1) { Sleep(2000);system("cls");
cout << "n ***************** MAIN MENU *****************" << endl
<< " Press 1. Enter new entry " << endl
<< " Press 2. view all entry " << endl
<< " Press 3. Delete an entry " << endl
<< " Press 4. Search the entry " << endl
<< " Press 5. delete all entries " << endl
<< " Press 6: To Exit"
<< "n --------------------------------------------- " << endl
<< "Your Choice :";
cin >> choice;

switch (choice)
{
case 1:
Link_List_Input(head, tail);
cout<<"nnttSaving Data ";
{Sleep(1000);
cout<<" .";}
break;
case 2:
Print_Link_List(head,tail);
break;
case 3:
Delete_Node_Contents(head);
break;
case 4:
Search_In_List(head,tail);
break;
case 5:
DeleteAll(head,tail);
break;
case 6:
cout << " n Exiting .... " << endl;
return 0;
default:
cout << "n Invalid Option, Please use any of the listed options"
<< endl;
}
}
}

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