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

C++ : Please include complete source code in answer This program will have names

ID: 3749905 • Letter: C

Question

C++ : Please include complete source code in answer This program will have names and addresses saved in a linked list. In addition, a birthday and anniversary date will be saved with each record. When the program is run, it will search for a birthday or an anniversary using the current date to compare with the saved date. It will then generate the appropriate card message. Because this will be an interactive system, your program should begin by displaying a menu. Items on the menu should include: • Enter a new name into the address book • Delete a name from the address book • Change a name or date in the address book • Display the whole address book • Generate birthday cards • Generate anniversary cards • Exit the card program Each of these sections will call individual functions to perform their appropriate task. This address book is to be sorted in alphabetical order. Be aware of this when you are entering, deleting, or changing the name, and plan your code accordingly. Use classes and objects where appropriate. Be sure to comment your code and use appropriate variable, function, and class names so that it is clear how the program flows. The user gets the menu and creates information to be stored in your address book. (To save sanity in testing, you may fill in 5 or 6 records within the code or written to a file to start your address book.) The user can add a new record to your existing ones, delete a record, modify a record or print the whole address book on the screen. For each of the options, make sure you give suitable prompts on the screen so that the user knows what is expected by the program. Expect that the user will enter both a birthday and anniversary date. (If you’d like, you can handle the situation where the user chooses not to enter an anniversary date.) A year may be entered or omitted in birthday and anniversary dates. Also be sure to redisplay the menu any time a function has concluded, until the user presses the Exit option. Create and display the card created on the screen (you do not need to print it). You may design the layout of the card as you wish. For example, it could be: Dear , Hope your birthday is really wonderful and this coming year is the best yet! Love, Joanne “Generate Birthday Cards” and “Generate Anniversary Cards” will use the system date (today) as the date to match. Using this date, display the card below it on the screen. Be ready to print multiple cards if more than one birthday or anniversary falls on the same day. “Display the Whole Address Book” will be done on the screen. Output should look something like: Wilson, Fred 123 Main Street Anytown, NJ 00000 Birthday: May 7 Anniversary: June 25 Or include the structure variable names you’ve used: lname: Wilson fname: Fred addr: 123 Main Street city: Anytown state: NJ zip: 00000 bday: May 7 aday: June 25

Explanation / Answer

ANSWER:

Hi, I am answering in 2 parts. First contains the main() function and the second part contains the required functions.

First Part:

/************************************************************************

* PROBLEM DEFINITION: *

* Just implimenting linked list of nodes using *

* structure of node. *

* *

* *

* *

*************************************************************************/

#include<iostream.h>

#include<conio.h>

#include<process.h>

// Here you can see a static int variable

struct node //count which is accessible to the all

{ //objects of the struct node i.e the value

static int count; //of the count is same for all objects of

int data, serial; //the the structures. (on the other hand

node* ptr; //distint objects of the node have distinct

//values of their data members, as usual.)

node() // NOTE: only declaration not initilization

{ // count is defined outside the class

data = 0; // APPLICATION:

ptr = NULL; // This count can be used to check

serial=count; // that which node is created at which time

count++; //

} //

//

}; //

//

int node::count=1; // here is the inililzation of the count.

void AddSpecific(node*);

node* AddNode(node*, node*);

node* Add1stNode(node*);

node* AddLastNode(node*);

void DisplayAll(node*);

node* SearchNode(node*);

int getLength(node*);

void updateNode(node*);

void sort(node*, int); //sort descending...

void CheckPosition(node*);

node* DeleteNode(node*);

#define ASSEN 0

#define DES 1

void main()

{

node* start;

node* current;

start=current=NULL;

char ch;

int temp, i;

start:

clrscr();

cout<<" 1- Insert node.";

cout<<" 2- Display all nodes.";

cout<<" 3- Search node by value.";

cout<<" 4- Delete node.";

cout<<" 5- Update node.";

cout<<" 6- Sort descending.";

cout<<" 7- Check positio after sorting.";

cout<<" 8- Exit.";

ch=getch();

switch(ch)

{

case '1':

{

clrscr();

cout<<" INSERT NODE";

if(start==NULL) //If no node is created yet.

{

cout<<" How many nod"

<<"es you want to insert?: ";

cin>>temp;

for(i=0;i<temp;i++)

{

if(i==0)

{

start=current=AddNode(start,current);

}

else

{

current=AddNode(start,current);

}

}//ending for loop

}//ending if

else

{

cout<<" a- Insert 1st node.";

cout<<" b- Insert specific.";

cout<<" c- Insert last.";

ch=getch();

switch(ch)

{

case 'a':

{

clrscr();

start=Add1stNode(start);

goto start;

break;

}//ending case a

case 'b':

{

clrscr();

AddSpecific(start);

goto start;

break;

}

case 'c':

{

clrscr();

current=AddNode(start,current);

goto start;

break;

}//ending case c

}//ending switch

}

goto start;

break;

}//ending case 1

case '2':

{

clrscr();

cout<<" DISPLAY ALL ";

DisplayAll(start);

getch();

goto start;

break;

}//ending case 2

case '3':

{

clrscr();

cout<<" SEARCH NODE BY VALUE";

SearchNode(start);

getch();

goto start;

break;

}//ending case 3

case '4':

{

clrscr();

cout<<" ---DELETE NODE---";

start=DeleteNode(start);

goto start;

break;

}//ending case 4

case '5':

{

clrscr();

updateNode(start);

getch();

goto start;

break;

}//ending case 5

case '6':

{

clrscr();

cout<<" ---CHOOSE AN ORDER---";

cout<<" 1- DESCENDING";

cout<<" 2- ASSCENDING";

ch=getch();

while(ch!='1'||'2')

{

switch(ch)

{

case '1':

{

sort(start,ASSEN);

goto start;

}

case '2':

{

sort(start,DES);

goto start;

}

}

}

getch();

goto start;

}

case '7':

{

cout<<" ---CHECK POSITOIN AFTER SORTING---";

CheckPosition(start);

getch();

goto start;

break;

}

case '8':

{

exit(1);

}//ending case 6

}//ending switch

}//ending main