SlideShare a Scribd company logo
1 of 23
Download to read offline
Hello Everyone!!!
I’m writing a c++ program that presents a menu to do the following options:
1. Create a linked list of names and phone numbers.
2. Insert a new structure in the linked list.
3. Modify an existing structure in the linked list.
4. Delete an existing structure in the linked list.
5. Find an existing structure from the linked list.
Comments:
* Inserting and modifying functios work perfect.
* Can you guys please tell me how to implement the deleting and the find functions. See my
code bellow, please run it and see what happens.
This is my code:
#include
#include
#include
#include
using namespace std;
struct TeleType
{
string Name;
string PhoneNum;
TeleType *NextAddr;
};
bool Check();
void Populate(TeleType *); // Populate Function Prototype.
void DisplayRecord(TeleType *); // DisplayRecord Function Prototype.
void InsertRecord(TeleType*, TeleType *); // InsertRecord Function Prototype.
void RemoveRecord(TeleType *, TeleType *); // RemoveRecord Function Prototype.
void ModifyRecord(TeleType *); // ModifyRecord Function Prototype.
void FindRecord(TeleType *); // Find Function Prototype.
TeleType *List; // Pointer
int main()
{
int Location = 0;
int Count = 0;
char Answery_n;
TeleType *Previous = NULL; //Pointer
TeleType *Record=NULL; // Pointer
TeleType *Current; // Pointer
List = new TeleType;
Current = List;
cout << "Please ";
do
{
Count++;
Populate(Current);
if (Check() == false)
{
cout << "Not storage available" << endl;
}
else
{
Current->NextAddr = new TeleType;
Current = Current->NextAddr;
cout << "Would you like to input more data? Y/N? :";
cin >> Answery_n;
cout << endl;
cin.get();
if (Answery_n != 'y')
{
Current->NextAddr = NULL;
break;
}
}
}
while (Answery_n == 'y');
cout << "The Linked list records: " << endl;
DisplayRecord(List);
cout << "There are " << Count << " records in the data file. " << endl<< endl;
while (1)
{
fflush(stdout);
cout << "Select from the menu" << endl;
cout << "1. Insert new structure in the linked list" << endl;
cout << "2. Modify an existing structure from the linked list" << endl;
cout << "3. Delete an existing structure from the linked list" << endl;
cout << "4. Find and existing structure from the linked list" << endl;
cout << "5. Exit from the program" << endl;
cin >> Answery_n;
// Inserting A New Structure.
if (Answery_n == '1')
{
cout << "Insert a new record after records 1, 2, 3..." << endl;
cin.get();
cin >> Location;
cout << endl;
Current = List;
if (Location > Count || Location < 1)
{
cout << "You must enter the value no grater than " << Count - 1
<< endl;
}
else
{
for (int i = 0; Current -> NextAddr != NULL; i++)
{
if (i == Location)
{
InsertRecord(Previous, Record);
Count++;
break;
}
else
{
Previous = Current;
Current = Current->NextAddr;
}
}
cout << "The list after insertion holds the following records"<< endl << endl;
DisplayRecord(List);
cout << "There are " << Count << " records." << endl << endl;
}
}
// Modifying An Existing Structure.
else if (Answery_n == '2')
{
cout << "Modify a record after records 1, 2, 3..." << endl;
cin >> Location;
cout << endl;
Current = List;
if (Location > Count || Location < 1)
{
cout << "You must enter the value no grater than " << Count - 1
<< endl;
}
else
{
for (int i = 0; Current -> NextAddr != NULL; i++)
{
if (i == Location)
{
ModifyRecord(Current);
}
else
{
Current = Current -> NextAddr;
}
}
cout << "The list after modification holds the following records"<< endl << endl;
DisplayRecord(List);
cout << "There are " << Count << " records." << endl << endl;
}
}
// Deleting An Existing Structure.
else if (Answery_n == '3')
{
cout << "Delete a record after records 1, 2, 3..." << endl;
cin >> Location;
cout << endl;
Current = List;
if (Location > Count || Location < 1)
{
cout << "You must enter the value no grater than " << Count - 1 << endl;
}
else
{
for (int i = 1; Current -> NextAddr != NULL; i++)
{
if (i == Location)
{
RemoveRecord(Previous, Current);
}
else
{
Previous = Current;
Current = Current -> NextAddr;
}
}
cout << "The list after deletion holds the following records"<< endl << endl;
DisplayRecord(List);
cout << "There are " << Count << " records." << endl << endl;
}
}
// Finding An Existing Structure.
else if(Answery_n == '4')
{
cout << "Find a new record 1, 2, 3..." << endl;
cin >> Location;
cout << endl;
List = new TeleType;
if(Location > Count || Location < 1)
{
cout << "You must enter the value no grater than " << Count - 1 << endl;
}
else
{
for(int i=1; List -> NextAddr != NULL; i++)
{
}
}
// Terminating Program.
} else if(Answery_n == '5')
{
cout << "Terminating the program" << endl;
exit(1);
}
else
{
cout << "Invalid Option entered" << endl;
}
}
while(Answery_n != 5);
return 0;
}
//Populate Function.
void Populate(TeleType *Record)
{
if(Record!=NULL)
{
cout << "Enter a name: ";
getline(cin, Record->Name);
cout << "Enter a phone number: ";
getline(cin, Record->PhoneNum);
}
}
//Display Record Function.
void DisplayRecord(TeleType *Contents)
{
while (Contents != NULL)
{
cout << endl << setiosflags(ios::left) << setw(30) << Contents->Name << setw(20)<<
Contents->PhoneNum;
Contents = Contents->NextAddr;
}
cout << endl;
return;
}
void InsertRecord(TeleType *Previous, TeleType *IR)//Insert Record Function.
{
cin.get();
IR = new TeleType;
Populate(IR);
if(Previous == NULL)
{
IR -> NextAddr = List;
List = IR;
}
else
{
IR -> NextAddr = Previous -> NextAddr;
Previous -> NextAddr = IR;
}
}
// Modify Record Function.
void ModifyRecord(TeleType *MR)
{
cin.get();
Populate(MR);
return;
}
// Remove Record Function.
void RemoveRecord(TeleType* Previous, TeleType* RR)
{
cin.get();
RR = Previous;
if(Previous == NULL)
{
RR -> NextAddr = List;
List = RR;
}
else
{
Previous -> NextAddr = RR -> NextAddr;
Previous -> NextAddr = RR;
}
}
// Find Record Function.
void FindRecord()
{
}
// Check Function.
bool Check()
{
if(new TeleType == NULL)
{
return false;
}
else
{
return true;
}
}
#include
#include
#include
#include
using namespace std;
struct TeleType
{
string Name;
string PhoneNum;
TeleType *NextAddr;
};
bool Check();
void Populate(TeleType *); // Populate Function Prototype.
void DisplayRecord(TeleType *); // DisplayRecord Function Prototype.
void InsertRecord(TeleType*, TeleType *); // InsertRecord Function Prototype.
void RemoveRecord(TeleType *, TeleType*); // RemoveRecord Function Prototype.
void ModifyRecord(TeleType *); // ModifyRecord Function Prototype.
void FindRecord(TeleType *); // Find Function Prototype.
TeleType *List; // Pointer
int main()
{
int Location = 0;
int Count = 0;
char Answery_n;
TeleType *Previous = NULL; //Pointer
TeleType *Record=NULL; // Pointer
TeleType *Current; // Pointer
List = new TeleType;
Current = List;
cout << "Please ";
do
{
Count++;
Populate(Current);
if (Check() == false)
{
cout << "Not storage available" << endl;
}
else
{
Current->NextAddr = new TeleType;
Current = Current->NextAddr;
cout << "Would you like to input more data? Y/N? :";
cin >> Answery_n;
cout << endl;
cin.get();
if (Answery_n != 'y')
{
Current->NextAddr = NULL;
break;
}
}
}
while (Answery_n == 'y');
cout << "The Linked list records: " << endl;
DisplayRecord(List);
cout << "There are " << Count << " records in the data file. " << endl<< endl;
while (1)
{
fflush(stdout);
cout << "Select from the menu" << endl;
cout << "1. Insert new structure in the linked list" << endl;
cout << "2. Modify an existing structure from the linked list" << endl;
cout << "3. Delete an existing structure from the linked list" << endl;
cout << "4. Find and existing structure from the linked list" << endl;
cout << "5. Exit from the program" << endl;
cin >> Answery_n;
// Inserting A New Structure.
if (Answery_n == '1')
{
cout << "Insert a record after records 1, 2, 3..." << endl;
cin.get();
cin >> Location;
cout << endl;
Current = List;
if (Location > Count || Location < 1)
{
cout << "You must enter the value no grater than " << Count - 1
<< endl;
}
else
{
for (int i = 0; Current -> NextAddr != NULL; i++)
{
if (i == Location)
{
InsertRecord(Previous, Record);
Count++;
break;
}
else
{
Previous = Current;
Current = Current->NextAddr;
}
}
cout << "The list after insertion holds the following records"<< endl << endl;
DisplayRecord(List);
cout << "There are " << Count << " records." << endl << endl;
}
}
// Modifying An Existing Structure.
else if (Answery_n == '2')
{
cout << "Modify a record after records 1, 2, 3..." << endl;
cin >> Location;
cout << endl;
Current = List;
if (Location > Count || Location < 1)
{
cout << "You must enter the value no grater than " << Count - 1
<< endl;
}
else
{
for (int i = 0; Current -> NextAddr != NULL; i++)
{
if (i == Location)
{
ModifyRecord(Current);
}
else
{
Current = Current -> NextAddr;
}
}
cout << "The list after modification holds the following records"<< endl << endl;
DisplayRecord(List);
cout << "There are " << Count << " records." << endl << endl;
}
}
// Deleting An Existing Structure.
else if (Answery_n == '3')
{
cout << "Delete a record after records 1, 2, 3..." << endl;
cin >> Location;
cout << endl;
Current = List;
if (Location > Count || Location < 1)
{
cout << "You must enter the value no grater than " << Count - 1 << endl;
}
else
{
for (int i = 0; Current -> NextAddr != NULL; i++)
{
if (i == Location)
{
RemoveRecord(Previous, Current);
}
else
{
Previous = Current;
Current = Current -> NextAddr;
}
}
cout << "The list after deletion holds the following records"<< endl << endl;
DisplayRecord(List);
cout << "There are " << Count << " records." << endl << endl;
}
}
// Finding An Existing Structure.
else if(Answery_n == '4')
{
cout << "Find an existing record" << endl;
cin >> Location;
cout << endl;
List = new TeleType;
if(Location > Count || Location < 1)
{
cout << "You must enter the value no grater than " << Count - 1 << endl;
}
else
{
for(int i=1; List -> NextAddr != NULL; i++)
{
}
}
// Terminating Program.
} else if(Answery_n == '5')
{
cout << "Terminating the program" << endl;
exit(1);
}
else
{
cout << "Invalid Option entered" << endl;
}
}
while(Answery_n != 5);
return 0;
}
//Populate Function.
void Populate(TeleType *Record)
{
if(Record!=NULL)
{
cout << "Enter a name: ";
getline(cin, Record->Name);
cout << "Enter a phone number: ";
getline(cin, Record->PhoneNum);
}
}
//Display Record Function.
void DisplayRecord(TeleType *Contents)
{
while (Contents != NULL)
{
cout << endl << setiosflags(ios::left) << setw(30) << Contents->Name << setw(20)<<
Contents->PhoneNum;
Contents = Contents->NextAddr;
}
cout << endl;
return;
}
void InsertRecord(TeleType *Previous, TeleType *IR)//Insert Record Function.
{
cin.get();
IR = new TeleType;
Populate(IR);
if(Previous == NULL)
{
IR -> NextAddr = List;
List = IR;
}
else
{
IR -> NextAddr = Previous -> NextAddr;
Previous -> NextAddr = IR;
}
}
// Modify Record Function.
void ModifyRecord(TeleType *MR)
{
cin.get();
Populate(MR);
return;
}
// Remove Record Function.
void RemoveRecord(TeleType *Previous, TeleType *RR)
{
cin.get();
RR = Previous;
if(Previous == NULL)
{
Previous -> NextAddr = List;
List -> NextAddr = Previous;
}
else
{
Previous -> NextAddr = RR -> NextAddr;
Previous -> NextAddr = RR;
}
}
// Find Record Function.
void FindRecord()
{
}
// Check Function.
bool Check()
{
if(new TeleType == NULL)
{
return false;
}
else
{
return true;
}
}
Solution
#include
#include
#include
#include
using namespace std;
struct TeleType
{
string Name;
string PhoneNum;
TeleType *NextAddr;
};
bool Check();
void Populate(TeleType *); // Populate Function Prototype.
void DisplayRecord(TeleType *); // DisplayRecord Function Prototype.
void InsertRecord(TeleType*, TeleType *); // InsertRecord Function Prototype.
void RemoveRecord(TeleType *, TeleType *); // RemoveRecord Function Prototype.
void ModifyRecord(TeleType *); // ModifyRecord Function Prototype.
void FindRecord(TeleType *); // Find Function Prototype.
int Count1(TeleType *);
TeleType *List; // Pointer
int main()
{
int Location = 0;
int Count = 0;
char Answery_n;
TeleType *Previous = NULL; //Pointer
TeleType *Record=NULL; // Pointer
TeleType *Current; // Pointer
List = new TeleType;
Current = List;
cout << "Please ";
do
{
Count++;
Populate(Current);
if (Check() == false)
{
cout << "Not storage available" << endl;
}
else
{
Current->NextAddr = new TeleType;
Current = Current->NextAddr;
cout << "Would you like to input more data? Y/N? :";
cin >> Answery_n;
cout << endl;
cin.get();
if (Answery_n != 'y')
{
Current->NextAddr = NULL;
break;
}
}
}
while (Answery_n == 'y');
cout << "The Linked list records: " << endl;
DisplayRecord(List);
cout << "There are " << Count1(List) << " records in the data file. " << endl<< endl;
while (1)
{
fflush(stdout);
cout << "Select from the menu" << endl;
cout << "1. Insert new structure in the linked list" << endl;
cout << "2. Modify an existing structure from the linked list" << endl;
cout << "3. Delete an existing structure from the linked list" << endl;
cout << "4. Find and existing structure from the linked list" << endl;
cout << "5. Exit from the program" << endl;
cin >> Answery_n;
// Inserting A New Structure.
if (Answery_n == '1')
{
cout << "Insert a new record after records 1, 2, 3..." << endl;
cin.get();
cin >> Location;
cout << endl;
Current = List;
if (Location > Count || Location < 1)
{
cout << "You must enter the value no grater than " << Count - 1
<< endl;
}
else
{
for (int i = 0; Current -> NextAddr != NULL; i++)
{
if (i == Location)
{
InsertRecord(Previous, Record);
Count++;
break;
}
else
{
Previous = Current;
Current = Current->NextAddr;
}
}
cout << "The list after insertion holds the following records"<< endl << endl;
DisplayRecord(List);
cout << "There are " << Count1(List) << " records." << endl << endl;
}
}
// Modifying An Existing Structure.
else if (Answery_n == '2')
{
cout << "Modify a record after records 1, 2, 3..." << endl;
cin >> Location;
cout << endl;
Current = List;
if (Location > Count || Location < 1)
{
cout << "You must enter the value no grater than " << Count - 1
<< endl;
}
else
{
for (int i = 0; Current -> NextAddr != NULL; i++)
{
if (i == Location)
{
ModifyRecord(Current);
}
else
{
Current = Current -> NextAddr;
}
}
cout << "The list after modification holds the following records"<< endl << endl;
DisplayRecord(List);
cout << "There are " << Count1(List) << " records." << endl << endl;
}
}
// Deleting An Existing Structure.
else if (Answery_n == '3')
{
cout << "Delete a record after records 1, 2, 3..." << endl;
cin >> Location;
cout << endl;
Current = List;
Previous = List ;
if (Location > Count || Location < 1)
{
cout << "You must enter the value no grater than " << Count - 1 << endl;
}
else
{
for (int i = 1; Current -> NextAddr != NULL; i++)
{
if (i == Location)
{
RemoveRecord(Previous, Current);
}
else
{
Previous = Current;
Current = Current -> NextAddr;
}
}
cout << "The list after deletion holds the following records"<< endl << endl;
DisplayRecord(List);
cout << "There are " << Count1(List) << " records." << endl << endl;
}
}
// Finding An Existing Structure.
else if(Answery_n == '4')
{
cout << "Find a new record 1, 2, 3..." << endl;
cin >> Location;
cout << endl;
//List = new TeleType;
TeleType *temp;
temp=List;
if(Location > Count || Location < 1)
{
cout << "You must enter the value no grater than " << Count - 1 << endl;
}
else
{
for(int i=1; iNextAddr;
}
cout<<"Element at "<< Location<<" is "<Name<<" and Phone is "<PhoneNum<Name);
cout << "Enter a phone number: ";
getline(cin, Record->PhoneNum);
}
}
//Display Record Function.
void DisplayRecord(TeleType *Contents)
{
while (Contents != NULL)
{
cout << endl << setiosflags(ios::left) << setw(30) << Contents->Name << setw(20)<< Contents-
>PhoneNum;
Contents = Contents->NextAddr;
}
cout << endl;
return;
}
void InsertRecord(TeleType *Previous, TeleType *IR)//Insert Record Function.
{
cin.get();
IR = new TeleType;
Populate(IR);
if(Previous == NULL)
{
IR -> NextAddr = List;
List = IR;
}
else
{
IR -> NextAddr = Previous -> NextAddr;
Previous -> NextAddr = IR;
}
}
// Modify Record Function.
void ModifyRecord(TeleType *MR)
{
cin.get();
Populate(MR);
return;
}
// Remove Record Function.
void RemoveRecord(TeleType* Previous, TeleType* RR)
{
cin.get();
TeleType *t,*t1;
t = Previous;
t1=RR;
if(t == t1)
{
List = t->NextAddr;
free(t);
free(t1);
}
else
{
t -> NextAddr = t1 -> NextAddr;
free(t1);
free(t);
}
}
// Find Record Function.
// Check Function.
bool Check()
{
if(new TeleType == NULL)
{
return false;
}
else
{
return true;
}
}
int Count1(TeleType* x)
{
if(x==NULL)
return -1;
else
return 1+Count1(x->NextAddr);
}

More Related Content

Similar to Hello Everyone!!!I’m writing a c++ program that presents a menu to.pdf

Write a program to find the number of comparisons using the binary se.docx
 Write a program to find the number of comparisons using the binary se.docx Write a program to find the number of comparisons using the binary se.docx
Write a program to find the number of comparisons using the binary se.docxajoy21
 
Lab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docxLab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docxteyaj1
 
#include iostream #includeData.h #includePerson.h#in.pdf
#include iostream #includeData.h #includePerson.h#in.pdf#include iostream #includeData.h #includePerson.h#in.pdf
#include iostream #includeData.h #includePerson.h#in.pdfannucommunication1
 
This is a c++ binary search program I worked so far but still cant g.pdf
This is a c++ binary search program I worked so far but still cant g.pdfThis is a c++ binary search program I worked so far but still cant g.pdf
This is a c++ binary search program I worked so far but still cant g.pdfkostikjaylonshaewe47
 
Implement the unsorted single linked list as we did in the class and .pdf
Implement the unsorted single linked list as we did in the class and .pdfImplement the unsorted single linked list as we did in the class and .pdf
Implement the unsorted single linked list as we did in the class and .pdfarihantstoneart
 
To write a program that implements the following C++ concepts 1. Dat.pdf
To write a program that implements the following C++ concepts 1. Dat.pdfTo write a program that implements the following C++ concepts 1. Dat.pdf
To write a program that implements the following C++ concepts 1. Dat.pdfSANDEEPARIHANT
 
Using C++I keep getting messagehead does not name a type.pdf
Using C++I keep getting messagehead does not name a type.pdfUsing C++I keep getting messagehead does not name a type.pdf
Using C++I keep getting messagehead does not name a type.pdfalokkesh1
 
Please help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdfPlease help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdfankit11134
 
For each task, submit your source java code file.(1) Objective Im.pdf
For each task, submit your source java code file.(1) Objective Im.pdfFor each task, submit your source java code file.(1) Objective Im.pdf
For each task, submit your source java code file.(1) Objective Im.pdfdhavalbl38
 
Need help getting past an error in C++! I have all my code pasted down.docx
Need help getting past an error in C++! I have all my code pasted down.docxNeed help getting past an error in C++! I have all my code pasted down.docx
Need help getting past an error in C++! I have all my code pasted down.docxJason0x0Scottw
 
So I already have most of the code and now I have to1. create an .pdf
So I already have most of the code and now I have to1. create an .pdfSo I already have most of the code and now I have to1. create an .pdf
So I already have most of the code and now I have to1. create an .pdfarjuncollection
 
In C++Write a recursive function to determine whether or not a Lin.pdf
In C++Write a recursive function to determine whether or not a Lin.pdfIn C++Write a recursive function to determine whether or not a Lin.pdf
In C++Write a recursive function to determine whether or not a Lin.pdfflashfashioncasualwe
 
#includeiostream #includecstdio #includecstdlib using na.pdf
#includeiostream #includecstdio #includecstdlib using na.pdf#includeiostream #includecstdio #includecstdlib using na.pdf
#includeiostream #includecstdio #includecstdlib using na.pdfharihelectronicspune
 
Computer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdfComputer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdfHIMANSUKUMAR12
 
Learn c++ (functions) with nauman ur rehman
Learn  c++ (functions) with nauman ur rehmanLearn  c++ (functions) with nauman ur rehman
Learn c++ (functions) with nauman ur rehmanNauman Rehman
 
Write a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdfWrite a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdfJUSTSTYLISH3B2MOHALI
 

Similar to Hello Everyone!!!I’m writing a c++ program that presents a menu to.pdf (20)

Write a program to find the number of comparisons using the binary se.docx
 Write a program to find the number of comparisons using the binary se.docx Write a program to find the number of comparisons using the binary se.docx
Write a program to find the number of comparisons using the binary se.docx
 
Lab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docxLab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docx
 
#include iostream #includeData.h #includePerson.h#in.pdf
#include iostream #includeData.h #includePerson.h#in.pdf#include iostream #includeData.h #includePerson.h#in.pdf
#include iostream #includeData.h #includePerson.h#in.pdf
 
CP 04.pptx
CP 04.pptxCP 04.pptx
CP 04.pptx
 
C++ practical
C++ practicalC++ practical
C++ practical
 
This is a c++ binary search program I worked so far but still cant g.pdf
This is a c++ binary search program I worked so far but still cant g.pdfThis is a c++ binary search program I worked so far but still cant g.pdf
This is a c++ binary search program I worked so far but still cant g.pdf
 
Implement the unsorted single linked list as we did in the class and .pdf
Implement the unsorted single linked list as we did in the class and .pdfImplement the unsorted single linked list as we did in the class and .pdf
Implement the unsorted single linked list as we did in the class and .pdf
 
To write a program that implements the following C++ concepts 1. Dat.pdf
To write a program that implements the following C++ concepts 1. Dat.pdfTo write a program that implements the following C++ concepts 1. Dat.pdf
To write a program that implements the following C++ concepts 1. Dat.pdf
 
Using C++I keep getting messagehead does not name a type.pdf
Using C++I keep getting messagehead does not name a type.pdfUsing C++I keep getting messagehead does not name a type.pdf
Using C++I keep getting messagehead does not name a type.pdf
 
Please help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdfPlease help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdf
 
Queue oop
Queue   oopQueue   oop
Queue oop
 
For each task, submit your source java code file.(1) Objective Im.pdf
For each task, submit your source java code file.(1) Objective Im.pdfFor each task, submit your source java code file.(1) Objective Im.pdf
For each task, submit your source java code file.(1) Objective Im.pdf
 
Need help getting past an error in C++! I have all my code pasted down.docx
Need help getting past an error in C++! I have all my code pasted down.docxNeed help getting past an error in C++! I have all my code pasted down.docx
Need help getting past an error in C++! I have all my code pasted down.docx
 
So I already have most of the code and now I have to1. create an .pdf
So I already have most of the code and now I have to1. create an .pdfSo I already have most of the code and now I have to1. create an .pdf
So I already have most of the code and now I have to1. create an .pdf
 
In C++Write a recursive function to determine whether or not a Lin.pdf
In C++Write a recursive function to determine whether or not a Lin.pdfIn C++Write a recursive function to determine whether or not a Lin.pdf
In C++Write a recursive function to determine whether or not a Lin.pdf
 
#includeiostream #includecstdio #includecstdlib using na.pdf
#includeiostream #includecstdio #includecstdlib using na.pdf#includeiostream #includecstdio #includecstdlib using na.pdf
#includeiostream #includecstdio #includecstdlib using na.pdf
 
Computer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdfComputer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdf
 
Learn c++ (functions) with nauman ur rehman
Learn  c++ (functions) with nauman ur rehmanLearn  c++ (functions) with nauman ur rehman
Learn c++ (functions) with nauman ur rehman
 
Write a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdfWrite a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdf
 
C# labprograms
C# labprogramsC# labprograms
C# labprograms
 

More from amittripathi2002

Hello out there in the math world !! Text Dennis Zills 9th Ed.pdf
Hello out there in the math world !! Text Dennis Zills 9th Ed.pdfHello out there in the math world !! Text Dennis Zills 9th Ed.pdf
Hello out there in the math world !! Text Dennis Zills 9th Ed.pdfamittripathi2002
 
Hello I cannot figure out how to do this problem. I tried looking up.pdf
Hello I cannot figure out how to do this problem. I tried looking up.pdfHello I cannot figure out how to do this problem. I tried looking up.pdf
Hello I cannot figure out how to do this problem. I tried looking up.pdfamittripathi2002
 
hello every body how are youall i am a student of BS acccounting and.pdf
hello every body how are youall i am a student of BS acccounting and.pdfhello every body how are youall i am a student of BS acccounting and.pdf
hello every body how are youall i am a student of BS acccounting and.pdfamittripathi2002
 
Having trouble about the answer of this two question 2. The ledger .pdf
Having trouble about the answer of this two question 2. The ledger .pdfHaving trouble about the answer of this two question 2. The ledger .pdf
Having trouble about the answer of this two question 2. The ledger .pdfamittripathi2002
 
Hawkins Township has two component units that it is required to incl.pdf
Hawkins Township has two component units that it is required to incl.pdfHawkins Township has two component units that it is required to incl.pdf
Hawkins Township has two component units that it is required to incl.pdfamittripathi2002
 
he academic planner of a university thinks that at least 35 of the .pdf
he academic planner of a university thinks that at least 35 of the .pdfhe academic planner of a university thinks that at least 35 of the .pdf
he academic planner of a university thinks that at least 35 of the .pdfamittripathi2002
 
Heavy equipment, which includes items such as buildings and robotics.pdf
Heavy equipment, which includes items such as buildings and robotics.pdfHeavy equipment, which includes items such as buildings and robotics.pdf
Heavy equipment, which includes items such as buildings and robotics.pdfamittripathi2002
 
Health care workers are at risk of being exposed to blood-borne path.pdf
Health care workers are at risk of being exposed to blood-borne path.pdfHealth care workers are at risk of being exposed to blood-borne path.pdf
Health care workers are at risk of being exposed to blood-borne path.pdfamittripathi2002
 
he time Z in minutes between calls to an electrical supply system ha.pdf
he time Z in minutes between calls to an electrical supply system ha.pdfhe time Z in minutes between calls to an electrical supply system ha.pdf
he time Z in minutes between calls to an electrical supply system ha.pdfamittripathi2002
 
Hayden Tool Company CaseThe Hayden Tool Company is located in a la.pdf
Hayden Tool Company CaseThe Hayden Tool Company is located in a la.pdfHayden Tool Company CaseThe Hayden Tool Company is located in a la.pdf
Hayden Tool Company CaseThe Hayden Tool Company is located in a la.pdfamittripathi2002
 
having a little trouble with integers Question Subtacting Integer.pdf
having a little trouble with integers Question Subtacting Integer.pdfhaving a little trouble with integers Question Subtacting Integer.pdf
having a little trouble with integers Question Subtacting Integer.pdfamittripathi2002
 
have a total of hundred people. of these 100 people 50 are democrati.pdf
have a total of hundred people. of these 100 people 50 are democrati.pdfhave a total of hundred people. of these 100 people 50 are democrati.pdf
have a total of hundred people. of these 100 people 50 are democrati.pdfamittripathi2002
 
Have labor unions outlived their usefulnessSolutionAnswer La.pdf
Have labor unions outlived their usefulnessSolutionAnswer La.pdfHave labor unions outlived their usefulnessSolutionAnswer La.pdf
Have labor unions outlived their usefulnessSolutionAnswer La.pdfamittripathi2002
 
Hatfield Medical Suppliess stock price had been lagging its industry.pdf
Hatfield Medical Suppliess stock price had been lagging its industry.pdfHatfield Medical Suppliess stock price had been lagging its industry.pdf
Hatfield Medical Suppliess stock price had been lagging its industry.pdfamittripathi2002
 
Hans JonasToward a Philosophy of Technology,1. What are the .pdf
Hans JonasToward a Philosophy of Technology,1. What are the .pdfHans JonasToward a Philosophy of Technology,1. What are the .pdf
Hans JonasToward a Philosophy of Technology,1. What are the .pdfamittripathi2002
 
Hannah Dakota’s experiment obtained reaction time data using a facto.pdf
Hannah Dakota’s experiment obtained reaction time data using a facto.pdfHannah Dakota’s experiment obtained reaction time data using a facto.pdf
Hannah Dakota’s experiment obtained reaction time data using a facto.pdfamittripathi2002
 
Had cable TV prices stayed low, would satellite TV service spread as.pdf
Had cable TV prices stayed low, would satellite TV service spread as.pdfHad cable TV prices stayed low, would satellite TV service spread as.pdf
Had cable TV prices stayed low, would satellite TV service spread as.pdfamittripathi2002
 
Harris, Schoen, and Hensley (1992) conducted a research study showin.pdf
Harris, Schoen, and Hensley (1992) conducted a research study showin.pdfHarris, Schoen, and Hensley (1992) conducted a research study showin.pdf
Harris, Schoen, and Hensley (1992) conducted a research study showin.pdfamittripathi2002
 
H0 Solution The test statistic is Z=(xbar-m.pdf
H0 Solution                     The test statistic is Z=(xbar-m.pdfH0 Solution                     The test statistic is Z=(xbar-m.pdf
H0 Solution The test statistic is Z=(xbar-m.pdfamittripathi2002
 

More from amittripathi2002 (19)

Hello out there in the math world !! Text Dennis Zills 9th Ed.pdf
Hello out there in the math world !! Text Dennis Zills 9th Ed.pdfHello out there in the math world !! Text Dennis Zills 9th Ed.pdf
Hello out there in the math world !! Text Dennis Zills 9th Ed.pdf
 
Hello I cannot figure out how to do this problem. I tried looking up.pdf
Hello I cannot figure out how to do this problem. I tried looking up.pdfHello I cannot figure out how to do this problem. I tried looking up.pdf
Hello I cannot figure out how to do this problem. I tried looking up.pdf
 
hello every body how are youall i am a student of BS acccounting and.pdf
hello every body how are youall i am a student of BS acccounting and.pdfhello every body how are youall i am a student of BS acccounting and.pdf
hello every body how are youall i am a student of BS acccounting and.pdf
 
Having trouble about the answer of this two question 2. The ledger .pdf
Having trouble about the answer of this two question 2. The ledger .pdfHaving trouble about the answer of this two question 2. The ledger .pdf
Having trouble about the answer of this two question 2. The ledger .pdf
 
Hawkins Township has two component units that it is required to incl.pdf
Hawkins Township has two component units that it is required to incl.pdfHawkins Township has two component units that it is required to incl.pdf
Hawkins Township has two component units that it is required to incl.pdf
 
he academic planner of a university thinks that at least 35 of the .pdf
he academic planner of a university thinks that at least 35 of the .pdfhe academic planner of a university thinks that at least 35 of the .pdf
he academic planner of a university thinks that at least 35 of the .pdf
 
Heavy equipment, which includes items such as buildings and robotics.pdf
Heavy equipment, which includes items such as buildings and robotics.pdfHeavy equipment, which includes items such as buildings and robotics.pdf
Heavy equipment, which includes items such as buildings and robotics.pdf
 
Health care workers are at risk of being exposed to blood-borne path.pdf
Health care workers are at risk of being exposed to blood-borne path.pdfHealth care workers are at risk of being exposed to blood-borne path.pdf
Health care workers are at risk of being exposed to blood-borne path.pdf
 
he time Z in minutes between calls to an electrical supply system ha.pdf
he time Z in minutes between calls to an electrical supply system ha.pdfhe time Z in minutes between calls to an electrical supply system ha.pdf
he time Z in minutes between calls to an electrical supply system ha.pdf
 
Hayden Tool Company CaseThe Hayden Tool Company is located in a la.pdf
Hayden Tool Company CaseThe Hayden Tool Company is located in a la.pdfHayden Tool Company CaseThe Hayden Tool Company is located in a la.pdf
Hayden Tool Company CaseThe Hayden Tool Company is located in a la.pdf
 
having a little trouble with integers Question Subtacting Integer.pdf
having a little trouble with integers Question Subtacting Integer.pdfhaving a little trouble with integers Question Subtacting Integer.pdf
having a little trouble with integers Question Subtacting Integer.pdf
 
have a total of hundred people. of these 100 people 50 are democrati.pdf
have a total of hundred people. of these 100 people 50 are democrati.pdfhave a total of hundred people. of these 100 people 50 are democrati.pdf
have a total of hundred people. of these 100 people 50 are democrati.pdf
 
Have labor unions outlived their usefulnessSolutionAnswer La.pdf
Have labor unions outlived their usefulnessSolutionAnswer La.pdfHave labor unions outlived their usefulnessSolutionAnswer La.pdf
Have labor unions outlived their usefulnessSolutionAnswer La.pdf
 
Hatfield Medical Suppliess stock price had been lagging its industry.pdf
Hatfield Medical Suppliess stock price had been lagging its industry.pdfHatfield Medical Suppliess stock price had been lagging its industry.pdf
Hatfield Medical Suppliess stock price had been lagging its industry.pdf
 
Hans JonasToward a Philosophy of Technology,1. What are the .pdf
Hans JonasToward a Philosophy of Technology,1. What are the .pdfHans JonasToward a Philosophy of Technology,1. What are the .pdf
Hans JonasToward a Philosophy of Technology,1. What are the .pdf
 
Hannah Dakota’s experiment obtained reaction time data using a facto.pdf
Hannah Dakota’s experiment obtained reaction time data using a facto.pdfHannah Dakota’s experiment obtained reaction time data using a facto.pdf
Hannah Dakota’s experiment obtained reaction time data using a facto.pdf
 
Had cable TV prices stayed low, would satellite TV service spread as.pdf
Had cable TV prices stayed low, would satellite TV service spread as.pdfHad cable TV prices stayed low, would satellite TV service spread as.pdf
Had cable TV prices stayed low, would satellite TV service spread as.pdf
 
Harris, Schoen, and Hensley (1992) conducted a research study showin.pdf
Harris, Schoen, and Hensley (1992) conducted a research study showin.pdfHarris, Schoen, and Hensley (1992) conducted a research study showin.pdf
Harris, Schoen, and Hensley (1992) conducted a research study showin.pdf
 
H0 Solution The test statistic is Z=(xbar-m.pdf
H0 Solution                     The test statistic is Z=(xbar-m.pdfH0 Solution                     The test statistic is Z=(xbar-m.pdf
H0 Solution The test statistic is Z=(xbar-m.pdf
 

Recently uploaded

Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdfssuserdda66b
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 

Recently uploaded (20)

Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 

Hello Everyone!!!I’m writing a c++ program that presents a menu to.pdf

  • 1. Hello Everyone!!! I’m writing a c++ program that presents a menu to do the following options: 1. Create a linked list of names and phone numbers. 2. Insert a new structure in the linked list. 3. Modify an existing structure in the linked list. 4. Delete an existing structure in the linked list. 5. Find an existing structure from the linked list. Comments: * Inserting and modifying functios work perfect. * Can you guys please tell me how to implement the deleting and the find functions. See my code bellow, please run it and see what happens. This is my code: #include #include #include #include using namespace std; struct TeleType { string Name; string PhoneNum; TeleType *NextAddr; }; bool Check(); void Populate(TeleType *); // Populate Function Prototype. void DisplayRecord(TeleType *); // DisplayRecord Function Prototype. void InsertRecord(TeleType*, TeleType *); // InsertRecord Function Prototype. void RemoveRecord(TeleType *, TeleType *); // RemoveRecord Function Prototype. void ModifyRecord(TeleType *); // ModifyRecord Function Prototype. void FindRecord(TeleType *); // Find Function Prototype. TeleType *List; // Pointer int main() {
  • 2. int Location = 0; int Count = 0; char Answery_n; TeleType *Previous = NULL; //Pointer TeleType *Record=NULL; // Pointer TeleType *Current; // Pointer List = new TeleType; Current = List; cout << "Please "; do { Count++; Populate(Current); if (Check() == false) { cout << "Not storage available" << endl; } else { Current->NextAddr = new TeleType; Current = Current->NextAddr; cout << "Would you like to input more data? Y/N? :"; cin >> Answery_n; cout << endl; cin.get(); if (Answery_n != 'y') { Current->NextAddr = NULL; break; } } } while (Answery_n == 'y'); cout << "The Linked list records: " << endl; DisplayRecord(List); cout << "There are " << Count << " records in the data file. " << endl<< endl;
  • 3. while (1) { fflush(stdout); cout << "Select from the menu" << endl; cout << "1. Insert new structure in the linked list" << endl; cout << "2. Modify an existing structure from the linked list" << endl; cout << "3. Delete an existing structure from the linked list" << endl; cout << "4. Find and existing structure from the linked list" << endl; cout << "5. Exit from the program" << endl; cin >> Answery_n; // Inserting A New Structure. if (Answery_n == '1') { cout << "Insert a new record after records 1, 2, 3..." << endl; cin.get(); cin >> Location; cout << endl; Current = List; if (Location > Count || Location < 1) { cout << "You must enter the value no grater than " << Count - 1 << endl; } else { for (int i = 0; Current -> NextAddr != NULL; i++) { if (i == Location) { InsertRecord(Previous, Record); Count++; break; } else { Previous = Current;
  • 4. Current = Current->NextAddr; } } cout << "The list after insertion holds the following records"<< endl << endl; DisplayRecord(List); cout << "There are " << Count << " records." << endl << endl; } } // Modifying An Existing Structure. else if (Answery_n == '2') { cout << "Modify a record after records 1, 2, 3..." << endl; cin >> Location; cout << endl; Current = List; if (Location > Count || Location < 1) { cout << "You must enter the value no grater than " << Count - 1 << endl; } else { for (int i = 0; Current -> NextAddr != NULL; i++) { if (i == Location) { ModifyRecord(Current); } else { Current = Current -> NextAddr; } } cout << "The list after modification holds the following records"<< endl << endl; DisplayRecord(List); cout << "There are " << Count << " records." << endl << endl;
  • 5. } } // Deleting An Existing Structure. else if (Answery_n == '3') { cout << "Delete a record after records 1, 2, 3..." << endl; cin >> Location; cout << endl; Current = List; if (Location > Count || Location < 1) { cout << "You must enter the value no grater than " << Count - 1 << endl; } else { for (int i = 1; Current -> NextAddr != NULL; i++) { if (i == Location) { RemoveRecord(Previous, Current); } else { Previous = Current; Current = Current -> NextAddr; } } cout << "The list after deletion holds the following records"<< endl << endl; DisplayRecord(List); cout << "There are " << Count << " records." << endl << endl; } } // Finding An Existing Structure. else if(Answery_n == '4') { cout << "Find a new record 1, 2, 3..." << endl;
  • 6. cin >> Location; cout << endl; List = new TeleType; if(Location > Count || Location < 1) { cout << "You must enter the value no grater than " << Count - 1 << endl; } else { for(int i=1; List -> NextAddr != NULL; i++) { } } // Terminating Program. } else if(Answery_n == '5') { cout << "Terminating the program" << endl; exit(1); } else { cout << "Invalid Option entered" << endl; } } while(Answery_n != 5); return 0; } //Populate Function. void Populate(TeleType *Record) { if(Record!=NULL) { cout << "Enter a name: "; getline(cin, Record->Name); cout << "Enter a phone number: "; getline(cin, Record->PhoneNum);
  • 7. } } //Display Record Function. void DisplayRecord(TeleType *Contents) { while (Contents != NULL) { cout << endl << setiosflags(ios::left) << setw(30) << Contents->Name << setw(20)<< Contents->PhoneNum; Contents = Contents->NextAddr; } cout << endl; return; } void InsertRecord(TeleType *Previous, TeleType *IR)//Insert Record Function. { cin.get(); IR = new TeleType; Populate(IR); if(Previous == NULL) { IR -> NextAddr = List; List = IR; } else { IR -> NextAddr = Previous -> NextAddr; Previous -> NextAddr = IR; } } // Modify Record Function. void ModifyRecord(TeleType *MR) { cin.get(); Populate(MR);
  • 8. return; } // Remove Record Function. void RemoveRecord(TeleType* Previous, TeleType* RR) { cin.get(); RR = Previous; if(Previous == NULL) { RR -> NextAddr = List; List = RR; } else { Previous -> NextAddr = RR -> NextAddr; Previous -> NextAddr = RR; } } // Find Record Function. void FindRecord() { } // Check Function. bool Check() { if(new TeleType == NULL) { return false; } else { return true; } } #include
  • 9. #include #include #include using namespace std; struct TeleType { string Name; string PhoneNum; TeleType *NextAddr; }; bool Check(); void Populate(TeleType *); // Populate Function Prototype. void DisplayRecord(TeleType *); // DisplayRecord Function Prototype. void InsertRecord(TeleType*, TeleType *); // InsertRecord Function Prototype. void RemoveRecord(TeleType *, TeleType*); // RemoveRecord Function Prototype. void ModifyRecord(TeleType *); // ModifyRecord Function Prototype. void FindRecord(TeleType *); // Find Function Prototype. TeleType *List; // Pointer int main() { int Location = 0; int Count = 0; char Answery_n; TeleType *Previous = NULL; //Pointer TeleType *Record=NULL; // Pointer TeleType *Current; // Pointer List = new TeleType; Current = List; cout << "Please "; do { Count++; Populate(Current); if (Check() == false) { cout << "Not storage available" << endl;
  • 10. } else { Current->NextAddr = new TeleType; Current = Current->NextAddr; cout << "Would you like to input more data? Y/N? :"; cin >> Answery_n; cout << endl; cin.get(); if (Answery_n != 'y') { Current->NextAddr = NULL; break; } } } while (Answery_n == 'y'); cout << "The Linked list records: " << endl; DisplayRecord(List); cout << "There are " << Count << " records in the data file. " << endl<< endl; while (1) { fflush(stdout); cout << "Select from the menu" << endl; cout << "1. Insert new structure in the linked list" << endl; cout << "2. Modify an existing structure from the linked list" << endl; cout << "3. Delete an existing structure from the linked list" << endl; cout << "4. Find and existing structure from the linked list" << endl; cout << "5. Exit from the program" << endl; cin >> Answery_n; // Inserting A New Structure. if (Answery_n == '1') { cout << "Insert a record after records 1, 2, 3..." << endl; cin.get(); cin >> Location;
  • 11. cout << endl; Current = List; if (Location > Count || Location < 1) { cout << "You must enter the value no grater than " << Count - 1 << endl; } else { for (int i = 0; Current -> NextAddr != NULL; i++) { if (i == Location) { InsertRecord(Previous, Record); Count++; break; } else { Previous = Current; Current = Current->NextAddr; } } cout << "The list after insertion holds the following records"<< endl << endl; DisplayRecord(List); cout << "There are " << Count << " records." << endl << endl; } } // Modifying An Existing Structure. else if (Answery_n == '2') { cout << "Modify a record after records 1, 2, 3..." << endl; cin >> Location; cout << endl; Current = List; if (Location > Count || Location < 1)
  • 12. { cout << "You must enter the value no grater than " << Count - 1 << endl; } else { for (int i = 0; Current -> NextAddr != NULL; i++) { if (i == Location) { ModifyRecord(Current); } else { Current = Current -> NextAddr; } } cout << "The list after modification holds the following records"<< endl << endl; DisplayRecord(List); cout << "There are " << Count << " records." << endl << endl; } } // Deleting An Existing Structure. else if (Answery_n == '3') { cout << "Delete a record after records 1, 2, 3..." << endl; cin >> Location; cout << endl; Current = List; if (Location > Count || Location < 1) { cout << "You must enter the value no grater than " << Count - 1 << endl; } else { for (int i = 0; Current -> NextAddr != NULL; i++)
  • 13. { if (i == Location) { RemoveRecord(Previous, Current); } else { Previous = Current; Current = Current -> NextAddr; } } cout << "The list after deletion holds the following records"<< endl << endl; DisplayRecord(List); cout << "There are " << Count << " records." << endl << endl; } } // Finding An Existing Structure. else if(Answery_n == '4') { cout << "Find an existing record" << endl; cin >> Location; cout << endl; List = new TeleType; if(Location > Count || Location < 1) { cout << "You must enter the value no grater than " << Count - 1 << endl; } else { for(int i=1; List -> NextAddr != NULL; i++) { } } // Terminating Program. } else if(Answery_n == '5') {
  • 14. cout << "Terminating the program" << endl; exit(1); } else { cout << "Invalid Option entered" << endl; } } while(Answery_n != 5); return 0; } //Populate Function. void Populate(TeleType *Record) { if(Record!=NULL) { cout << "Enter a name: "; getline(cin, Record->Name); cout << "Enter a phone number: "; getline(cin, Record->PhoneNum); } } //Display Record Function. void DisplayRecord(TeleType *Contents) { while (Contents != NULL) { cout << endl << setiosflags(ios::left) << setw(30) << Contents->Name << setw(20)<< Contents->PhoneNum; Contents = Contents->NextAddr; } cout << endl; return; } void InsertRecord(TeleType *Previous, TeleType *IR)//Insert Record Function.
  • 15. { cin.get(); IR = new TeleType; Populate(IR); if(Previous == NULL) { IR -> NextAddr = List; List = IR; } else { IR -> NextAddr = Previous -> NextAddr; Previous -> NextAddr = IR; } } // Modify Record Function. void ModifyRecord(TeleType *MR) { cin.get(); Populate(MR); return; } // Remove Record Function. void RemoveRecord(TeleType *Previous, TeleType *RR) { cin.get(); RR = Previous; if(Previous == NULL) { Previous -> NextAddr = List; List -> NextAddr = Previous; } else { Previous -> NextAddr = RR -> NextAddr; Previous -> NextAddr = RR;
  • 16. } } // Find Record Function. void FindRecord() { } // Check Function. bool Check() { if(new TeleType == NULL) { return false; } else { return true; } } Solution #include #include #include #include using namespace std; struct TeleType { string Name; string PhoneNum; TeleType *NextAddr; }; bool Check(); void Populate(TeleType *); // Populate Function Prototype. void DisplayRecord(TeleType *); // DisplayRecord Function Prototype. void InsertRecord(TeleType*, TeleType *); // InsertRecord Function Prototype.
  • 17. void RemoveRecord(TeleType *, TeleType *); // RemoveRecord Function Prototype. void ModifyRecord(TeleType *); // ModifyRecord Function Prototype. void FindRecord(TeleType *); // Find Function Prototype. int Count1(TeleType *); TeleType *List; // Pointer int main() { int Location = 0; int Count = 0; char Answery_n; TeleType *Previous = NULL; //Pointer TeleType *Record=NULL; // Pointer TeleType *Current; // Pointer List = new TeleType; Current = List; cout << "Please "; do { Count++; Populate(Current); if (Check() == false) { cout << "Not storage available" << endl; } else { Current->NextAddr = new TeleType; Current = Current->NextAddr; cout << "Would you like to input more data? Y/N? :"; cin >> Answery_n; cout << endl; cin.get(); if (Answery_n != 'y') { Current->NextAddr = NULL; break;
  • 18. } } } while (Answery_n == 'y'); cout << "The Linked list records: " << endl; DisplayRecord(List); cout << "There are " << Count1(List) << " records in the data file. " << endl<< endl; while (1) { fflush(stdout); cout << "Select from the menu" << endl; cout << "1. Insert new structure in the linked list" << endl; cout << "2. Modify an existing structure from the linked list" << endl; cout << "3. Delete an existing structure from the linked list" << endl; cout << "4. Find and existing structure from the linked list" << endl; cout << "5. Exit from the program" << endl; cin >> Answery_n; // Inserting A New Structure. if (Answery_n == '1') { cout << "Insert a new record after records 1, 2, 3..." << endl; cin.get(); cin >> Location; cout << endl; Current = List; if (Location > Count || Location < 1) { cout << "You must enter the value no grater than " << Count - 1 << endl; } else { for (int i = 0; Current -> NextAddr != NULL; i++) { if (i == Location) {
  • 19. InsertRecord(Previous, Record); Count++; break; } else { Previous = Current; Current = Current->NextAddr; } } cout << "The list after insertion holds the following records"<< endl << endl; DisplayRecord(List); cout << "There are " << Count1(List) << " records." << endl << endl; } } // Modifying An Existing Structure. else if (Answery_n == '2') { cout << "Modify a record after records 1, 2, 3..." << endl; cin >> Location; cout << endl; Current = List; if (Location > Count || Location < 1) { cout << "You must enter the value no grater than " << Count - 1 << endl; } else { for (int i = 0; Current -> NextAddr != NULL; i++) { if (i == Location) { ModifyRecord(Current); } else
  • 20. { Current = Current -> NextAddr; } } cout << "The list after modification holds the following records"<< endl << endl; DisplayRecord(List); cout << "There are " << Count1(List) << " records." << endl << endl; } } // Deleting An Existing Structure. else if (Answery_n == '3') { cout << "Delete a record after records 1, 2, 3..." << endl; cin >> Location; cout << endl; Current = List; Previous = List ; if (Location > Count || Location < 1) { cout << "You must enter the value no grater than " << Count - 1 << endl; } else { for (int i = 1; Current -> NextAddr != NULL; i++) { if (i == Location) { RemoveRecord(Previous, Current); } else { Previous = Current; Current = Current -> NextAddr; } } cout << "The list after deletion holds the following records"<< endl << endl;
  • 21. DisplayRecord(List); cout << "There are " << Count1(List) << " records." << endl << endl; } } // Finding An Existing Structure. else if(Answery_n == '4') { cout << "Find a new record 1, 2, 3..." << endl; cin >> Location; cout << endl; //List = new TeleType; TeleType *temp; temp=List; if(Location > Count || Location < 1) { cout << "You must enter the value no grater than " << Count - 1 << endl; } else { for(int i=1; iNextAddr; } cout<<"Element at "<< Location<<" is "<Name<<" and Phone is "<PhoneNum<Name); cout << "Enter a phone number: "; getline(cin, Record->PhoneNum); } } //Display Record Function. void DisplayRecord(TeleType *Contents) { while (Contents != NULL) { cout << endl << setiosflags(ios::left) << setw(30) << Contents->Name << setw(20)<< Contents- >PhoneNum; Contents = Contents->NextAddr; } cout << endl;
  • 22. return; } void InsertRecord(TeleType *Previous, TeleType *IR)//Insert Record Function. { cin.get(); IR = new TeleType; Populate(IR); if(Previous == NULL) { IR -> NextAddr = List; List = IR; } else { IR -> NextAddr = Previous -> NextAddr; Previous -> NextAddr = IR; } } // Modify Record Function. void ModifyRecord(TeleType *MR) { cin.get(); Populate(MR); return; } // Remove Record Function. void RemoveRecord(TeleType* Previous, TeleType* RR) { cin.get(); TeleType *t,*t1; t = Previous; t1=RR; if(t == t1) { List = t->NextAddr;
  • 23. free(t); free(t1); } else { t -> NextAddr = t1 -> NextAddr; free(t1); free(t); } } // Find Record Function. // Check Function. bool Check() { if(new TeleType == NULL) { return false; } else { return true; } } int Count1(TeleType* x) { if(x==NULL) return -1; else return 1+Count1(x->NextAddr); }