SlideShare a Scribd company logo
Help with the following code:
1. Rewrite to be contained in a vector object.
2. Using linked lists, redo to handle as many entries as required.
3. Add the ability to add or delete a new entry to the address book.
4. When the program terminates, write the data in the address book to a disk.
# include
# include
# include
using namespace std;
class addressbook
{
private:
char name[500];
long ph_num; //class addressType :public addressbook
char address[500];
int year;
int mounth;
int day;
char gender;
int d, Th, y;
char M, F, m, f;
// char freind[];
public:
addressbook();
void setName();
void getName();
void getphone();
long setphone();
void setAddress();
void getAddress();
float getAverage();
int setDay();
void getDay();
int setMounth();
void getMounth();
int setYear();
void getYear();
char setGender();
void getGender();
};
addressbook::addressbook() // constructor
{
name;
ph_num = 0;
year = 0;
mounth = 0;
day = 0;
}
int addressbook::setDay()
{
cout << " tEnter the day: t" << endl;
cin >> d;
day = (d >= 1 && d<32) ? d : 0;
return day;
}
int addressbook::setMounth()
{
cout << " tEnter the mounth: t" << endl;
cin >> m;
mounth = (Th >= 1 && Th<13) ? Th : 0;
return mounth;
}
int addressbook::setYear()
{
cout << " tEnter the year : t" << endl;
cin >> y;
year = (y >= 1 && y<2008) ? y : 0;
return year;
}
void addressbook::getMounth()
{
cout << mounth << "/";
}
void addressbook::getDay()
{
cout << "tBIRTH DAY : " << day << "/";
}
void addressbook::getYear()
{
cout << year;
}
char addressbook::setGender()
{
int flag = 0;
cout << "  tEnter the gender,(F)for female (M)for male: t";
cin >> gender;
while (flag != 1)
{
if (gender == ('F') || gender == ('M') || gender == ('m') || gender == ('f'))
flag = 1;
else
{
cout << "t error.....Try Again t";
cin >> gender;
return gender;
}
}
}
void addressbook::getGender()
{
cout << "tGender : " << gender << endl;
}
void addressbook::getAddress()
{
cout << "tAddress : " << address << endl;
}
float addressbook::getAverage()
{
return 0.0f;
}
void addressbook::setAddress()
{
cout << "  tEnter the address: t" << endl;
gets_s(address);
}
void addressbook::setName()
{
cout << " tEnter the name: t" << endl;
gets_s(name);
}
void addressbook::getName()
{
cout << " tName : " << name << " " << endl;
}
long addressbook::setphone()
{
cout << "  tEnter the person number: t" << endl;
cin >> ph_num;
return ph_num;
}
void addressbook::getphone()
{
cout << "tPerson # : " << ph_num << endl;
}
/*class addressType :public addressbook
{
do that
};*/
int main()
{
int s;
cout << " Enter number person max(500): ";
cin >> s;
addressbook book[10];
for (int i = 1; i<2; i++)
{
book[i].setName();
book[i].setphone();
book[i].setAddress();
book[i].setDay();
book[i].setMounth();
book[i].setYear();
book[i].setGender();
cout << "  *********************************** ";
}
for (int u = 0; u<2; u++)
{
book[u].getName();
book[u].getphone();
book[u].getAddress();
book[u].getGender();
book[u].getDay();
book[u].getMounth();
book[u].getYear();
}
_getch();
}
Solution
Question 1
Changes to be made in the code:
Instead of:
char name[500];
write:
vector name(500);
similarly, instead of:
char address[500];
change it to:
vector address(500);
and finally change
addressbook book[10];
to:
vector book(10);
You might have figured it out by the changes but for reference, changing an array to vector has
to be done by mentioning "vector" followed by the "data_type" inside "<>" and then
mentioning the name of the identifier(variable) like in an array and providing its size, but the size
has to be inside "()" instead of "[]".
Edit1- include the vector header file at the header section as:
#include
Here is the complete code-
# include
# include
# include
#include
using namespace std;
class addressbook
{
private:
vector name(500);
long ph_num; //class addressType :public addressbook
vector address(500);
int year;
int mounth;
int day;
char gender;
int d, Th, y;
char M, F, m, f;
// char freind[];
public:
addressbook();
void setName();
void getName();
void getphone();
long setphone();
void setAddress();
void getAddress();
float getAverage();
int setDay();
void getDay();
int setMounth();
void getMounth();
int setYear();
void getYear();
char setGender();
void getGender();
};
addressbook::addressbook() // constructor
{
name;
ph_num = 0;
year = 0;
mounth = 0;
day = 0;
}
int addressbook::setDay()
{
cout << " tEnter the day: t" << endl;
cin >> d;
day = (d >= 1 && d<32) ? d : 0;
return day;
}
int addressbook::setMounth()
{
cout << " tEnter the mounth: t" << endl;
cin >> m;
mounth = (Th >= 1 && Th<13) ? Th : 0;
return mounth;
}
int addressbook::setYear()
{
cout << " tEnter the year : t" << endl;
cin >> y;
year = (y >= 1 && y<2008) ? y : 0;
return year;
}
void addressbook::getMounth()
{
cout << mounth << "/";
}
void addressbook::getDay()
{
cout << "tBIRTH DAY : " << day << "/";
}
void addressbook::getYear()
{
cout << year;
}
char addressbook::setGender()
{
int flag = 0;
cout << "  tEnter the gender,(F)for female (M)for male: t";
cin >> gender;
while (flag != 1)
{
if (gender == ('F') || gender == ('M') || gender == ('m') || gender == ('f'))
flag = 1;
else
{
cout << "t error.....Try Again t";
cin >> gender;
return gender;
}
}
}
void addressbook::getGender()
{
cout << "tGender : " << gender << endl;
}
void addressbook::getAddress()
{
cout << "tAddress : " << address << endl;
}
float addressbook::getAverage()
{
return 0.0f;
}
void addressbook::setAddress()
{
cout << "  tEnter the address: t" << endl;
gets_s(address);
}
void addressbook::setName()
{
cout << " tEnter the name: t" << endl;
gets_s(name);
}
void addressbook::getName()
{
cout << " tName : " << name << " " << endl;
}
long addressbook::setphone()
{
cout << "  tEnter the person number: t" << endl;
cin >> ph_num;
return ph_num;
}
void addressbook::getphone()
{
cout << "tPerson # : " << ph_num << endl;
}
/*class addressType :public addressbook
{
do that
};*/
int main()
{
int s;
cout << " Enter number person max(500): ";
cin >> s;
vector book(10);
for (int i = 1; i<2; i++)
{
book[i].setName();
book[i].setphone();
book[i].setAddress();
book[i].setDay();
book[i].setMounth();
book[i].setYear();
book[i].setGender();
cout << "  *********************************** ";
}
for (int u = 0; u<2; u++)
{
book[u].getName();
book[u].getphone();
book[u].getAddress();
book[u].getGender();
book[u].getDay();
book[u].getMounth();
book[u].getYear();
}
_getch();
}

More Related Content

Similar to Help with the following code1. Rewrite to be contained in a vecto.pdf

C++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorC++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorJussi Pohjolainen
 
So here is the code from the previous assignment that we need to ext.pdf
So here is the code from the previous assignment that we need to ext.pdfSo here is the code from the previous assignment that we need to ext.pdf
So here is the code from the previous assignment that we need to ext.pdf
leolight2
 
Dns server clients (actual program)
Dns server clients (actual program)Dns server clients (actual program)
Dns server clients (actual program)Youssef Dirani
 
Dns server clients (actual program)
Dns server clients (actual program)Dns server clients (actual program)
Dns server clients (actual program)Youssef Dirani
 
Use the code below from the previous assignment that we need to exte.pdf
Use the code below from the previous assignment that we need to exte.pdfUse the code below from the previous assignment that we need to exte.pdf
Use the code below from the previous assignment that we need to exte.pdf
sales87
 
Computer practicals(part) Class 12
Computer practicals(part) Class 12Computer practicals(part) Class 12
Computer practicals(part) Class 12
अयशकांत मिश्र
 
Pointers
PointersPointers
Pointers
rajshreemuthiah
 
c++ project on restaurant billing
c++ project on restaurant billing c++ project on restaurant billing
c++ project on restaurant billing
Swakriti Rathore
 
Slide set 6 Strings and pointers.pdf
Slide set 6 Strings and pointers.pdfSlide set 6 Strings and pointers.pdf
Slide set 6 Strings and pointers.pdf
HimanshuKansal22
 
12
1212
C++ practical
C++ practicalC++ practical
C++ practical
Rahul juneja
 
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
kostikjaylonshaewe47
 
why will it not display all of the entries-- output -nMenu n-Add Entr.pdf
why will it not display all of the entries--  output -nMenu n-Add Entr.pdfwhy will it not display all of the entries--  output -nMenu n-Add Entr.pdf
why will it not display all of the entries-- output -nMenu n-Add Entr.pdf
abc2232
 
Pointer
PointerPointer
Pointer
Fahuda E
 
computer notes - Data Structures - 3
computer notes - Data Structures - 3computer notes - Data Structures - 3
computer notes - Data Structures - 3ecomputernotes
 
Pointers
PointersPointers
Pointers
sanya6900
 
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdfDoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
aathiauto
 
Lab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docxLab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docx
teyaj1
 

Similar to Help with the following code1. Rewrite to be contained in a vecto.pdf (20)

oop Lecture 4
oop Lecture 4oop Lecture 4
oop Lecture 4
 
C++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorC++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operator
 
So here is the code from the previous assignment that we need to ext.pdf
So here is the code from the previous assignment that we need to ext.pdfSo here is the code from the previous assignment that we need to ext.pdf
So here is the code from the previous assignment that we need to ext.pdf
 
Dns server clients (actual program)
Dns server clients (actual program)Dns server clients (actual program)
Dns server clients (actual program)
 
Dns server clients (actual program)
Dns server clients (actual program)Dns server clients (actual program)
Dns server clients (actual program)
 
Use the code below from the previous assignment that we need to exte.pdf
Use the code below from the previous assignment that we need to exte.pdfUse the code below from the previous assignment that we need to exte.pdf
Use the code below from the previous assignment that we need to exte.pdf
 
C program
C programC program
C program
 
Computer practicals(part) Class 12
Computer practicals(part) Class 12Computer practicals(part) Class 12
Computer practicals(part) Class 12
 
Pointers
PointersPointers
Pointers
 
c++ project on restaurant billing
c++ project on restaurant billing c++ project on restaurant billing
c++ project on restaurant billing
 
Slide set 6 Strings and pointers.pdf
Slide set 6 Strings and pointers.pdfSlide set 6 Strings and pointers.pdf
Slide set 6 Strings and pointers.pdf
 
12
1212
12
 
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
 
why will it not display all of the entries-- output -nMenu n-Add Entr.pdf
why will it not display all of the entries--  output -nMenu n-Add Entr.pdfwhy will it not display all of the entries--  output -nMenu n-Add Entr.pdf
why will it not display all of the entries-- output -nMenu n-Add Entr.pdf
 
Pointer
PointerPointer
Pointer
 
computer notes - Data Structures - 3
computer notes - Data Structures - 3computer notes - Data Structures - 3
computer notes - Data Structures - 3
 
Pointers
PointersPointers
Pointers
 
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdfDoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
 
Lab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docxLab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docx
 

More from ezzi97

Explain why multiple processes cannot share data easilySolution.pdf
Explain why multiple processes cannot share data easilySolution.pdfExplain why multiple processes cannot share data easilySolution.pdf
Explain why multiple processes cannot share data easilySolution.pdf
ezzi97
 
executive summary for law enforcement using dronesSolutionUse .pdf
executive summary for law enforcement using dronesSolutionUse .pdfexecutive summary for law enforcement using dronesSolutionUse .pdf
executive summary for law enforcement using dronesSolutionUse .pdf
ezzi97
 
Discuss how your life and experience with social mediaweb 2.0 compa.pdf
Discuss how your life and experience with social mediaweb 2.0 compa.pdfDiscuss how your life and experience with social mediaweb 2.0 compa.pdf
Discuss how your life and experience with social mediaweb 2.0 compa.pdf
ezzi97
 
create a narrative budget blueprint for a local unit of government. .pdf
create a narrative budget blueprint for a local unit of government. .pdfcreate a narrative budget blueprint for a local unit of government. .pdf
create a narrative budget blueprint for a local unit of government. .pdf
ezzi97
 
define three types of kernal-mode to user mode transfersSolution.pdf
define three types of kernal-mode to user mode transfersSolution.pdfdefine three types of kernal-mode to user mode transfersSolution.pdf
define three types of kernal-mode to user mode transfersSolution.pdf
ezzi97
 
Arrange the steps of DNA replication in the order that they occur. D.pdf
Arrange the steps of DNA replication in the order that they occur.  D.pdfArrange the steps of DNA replication in the order that they occur.  D.pdf
Arrange the steps of DNA replication in the order that they occur. D.pdf
ezzi97
 
C++You will design a program to play a simplified version of war, .pdf
C++You will design a program to play a simplified version of war, .pdfC++You will design a program to play a simplified version of war, .pdf
C++You will design a program to play a simplified version of war, .pdf
ezzi97
 
(c) After conducting several measurements, the Beijing Municipal Env.pdf
(c) After conducting several measurements, the Beijing Municipal Env.pdf(c) After conducting several measurements, the Beijing Municipal Env.pdf
(c) After conducting several measurements, the Beijing Municipal Env.pdf
ezzi97
 
1. Which of the following statements would correctly print out t.pdf
1. Which of the following statements would correctly print out t.pdf1. Which of the following statements would correctly print out t.pdf
1. Which of the following statements would correctly print out t.pdf
ezzi97
 
2.How important is it to involve physicians in financial improvement.pdf
2.How important is it to involve physicians in financial improvement.pdf2.How important is it to involve physicians in financial improvement.pdf
2.How important is it to involve physicians in financial improvement.pdf
ezzi97
 
Write one page essay to explain how you relate signals and systems t.pdf
Write one page essay to explain how you relate signals and systems t.pdfWrite one page essay to explain how you relate signals and systems t.pdf
Write one page essay to explain how you relate signals and systems t.pdf
ezzi97
 
Why do IDPs & IDRs lack structure Lack a ligand or partner Denatu.pdf
Why do IDPs & IDRs lack structure  Lack a ligand or partner  Denatu.pdfWhy do IDPs & IDRs lack structure  Lack a ligand or partner  Denatu.pdf
Why do IDPs & IDRs lack structure Lack a ligand or partner Denatu.pdf
ezzi97
 
Write 2 to 3 paragraphs aboutONE DDoS attack that occurred in 2016.pdf
Write 2 to 3 paragraphs aboutONE DDoS attack that occurred in 2016.pdfWrite 2 to 3 paragraphs aboutONE DDoS attack that occurred in 2016.pdf
Write 2 to 3 paragraphs aboutONE DDoS attack that occurred in 2016.pdf
ezzi97
 
Why is methyl salicylate not appreciably soluble in waterSoluti.pdf
Why is methyl salicylate not appreciably soluble in waterSoluti.pdfWhy is methyl salicylate not appreciably soluble in waterSoluti.pdf
Why is methyl salicylate not appreciably soluble in waterSoluti.pdf
ezzi97
 
Who are stakeholders Define who they are and then please share what.pdf
Who are stakeholders Define who they are and then please share what.pdfWho are stakeholders Define who they are and then please share what.pdf
Who are stakeholders Define who they are and then please share what.pdf
ezzi97
 
What was the biggest problem with the Articles of Confederation They.pdf
What was the biggest problem with the Articles of Confederation They.pdfWhat was the biggest problem with the Articles of Confederation They.pdf
What was the biggest problem with the Articles of Confederation They.pdf
ezzi97
 
What is UWIN and what does it doSolutionUWin is a software .pdf
What is UWIN and what does it doSolutionUWin is a software .pdfWhat is UWIN and what does it doSolutionUWin is a software .pdf
What is UWIN and what does it doSolutionUWin is a software .pdf
ezzi97
 
What sort of archaeological remains have been discovered on the site.pdf
What sort of archaeological remains have been discovered on the site.pdfWhat sort of archaeological remains have been discovered on the site.pdf
What sort of archaeological remains have been discovered on the site.pdf
ezzi97
 
Link to assignment that I need help with is below httpweb.cse..pdf
Link to assignment that I need help with is below httpweb.cse..pdfLink to assignment that I need help with is below httpweb.cse..pdf
Link to assignment that I need help with is below httpweb.cse..pdf
ezzi97
 
The Food Stamp Program is Americas first line of defense against hu.pdf
The Food Stamp Program is Americas first line of defense against hu.pdfThe Food Stamp Program is Americas first line of defense against hu.pdf
The Food Stamp Program is Americas first line of defense against hu.pdf
ezzi97
 

More from ezzi97 (20)

Explain why multiple processes cannot share data easilySolution.pdf
Explain why multiple processes cannot share data easilySolution.pdfExplain why multiple processes cannot share data easilySolution.pdf
Explain why multiple processes cannot share data easilySolution.pdf
 
executive summary for law enforcement using dronesSolutionUse .pdf
executive summary for law enforcement using dronesSolutionUse .pdfexecutive summary for law enforcement using dronesSolutionUse .pdf
executive summary for law enforcement using dronesSolutionUse .pdf
 
Discuss how your life and experience with social mediaweb 2.0 compa.pdf
Discuss how your life and experience with social mediaweb 2.0 compa.pdfDiscuss how your life and experience with social mediaweb 2.0 compa.pdf
Discuss how your life and experience with social mediaweb 2.0 compa.pdf
 
create a narrative budget blueprint for a local unit of government. .pdf
create a narrative budget blueprint for a local unit of government. .pdfcreate a narrative budget blueprint for a local unit of government. .pdf
create a narrative budget blueprint for a local unit of government. .pdf
 
define three types of kernal-mode to user mode transfersSolution.pdf
define three types of kernal-mode to user mode transfersSolution.pdfdefine three types of kernal-mode to user mode transfersSolution.pdf
define three types of kernal-mode to user mode transfersSolution.pdf
 
Arrange the steps of DNA replication in the order that they occur. D.pdf
Arrange the steps of DNA replication in the order that they occur.  D.pdfArrange the steps of DNA replication in the order that they occur.  D.pdf
Arrange the steps of DNA replication in the order that they occur. D.pdf
 
C++You will design a program to play a simplified version of war, .pdf
C++You will design a program to play a simplified version of war, .pdfC++You will design a program to play a simplified version of war, .pdf
C++You will design a program to play a simplified version of war, .pdf
 
(c) After conducting several measurements, the Beijing Municipal Env.pdf
(c) After conducting several measurements, the Beijing Municipal Env.pdf(c) After conducting several measurements, the Beijing Municipal Env.pdf
(c) After conducting several measurements, the Beijing Municipal Env.pdf
 
1. Which of the following statements would correctly print out t.pdf
1. Which of the following statements would correctly print out t.pdf1. Which of the following statements would correctly print out t.pdf
1. Which of the following statements would correctly print out t.pdf
 
2.How important is it to involve physicians in financial improvement.pdf
2.How important is it to involve physicians in financial improvement.pdf2.How important is it to involve physicians in financial improvement.pdf
2.How important is it to involve physicians in financial improvement.pdf
 
Write one page essay to explain how you relate signals and systems t.pdf
Write one page essay to explain how you relate signals and systems t.pdfWrite one page essay to explain how you relate signals and systems t.pdf
Write one page essay to explain how you relate signals and systems t.pdf
 
Why do IDPs & IDRs lack structure Lack a ligand or partner Denatu.pdf
Why do IDPs & IDRs lack structure  Lack a ligand or partner  Denatu.pdfWhy do IDPs & IDRs lack structure  Lack a ligand or partner  Denatu.pdf
Why do IDPs & IDRs lack structure Lack a ligand or partner Denatu.pdf
 
Write 2 to 3 paragraphs aboutONE DDoS attack that occurred in 2016.pdf
Write 2 to 3 paragraphs aboutONE DDoS attack that occurred in 2016.pdfWrite 2 to 3 paragraphs aboutONE DDoS attack that occurred in 2016.pdf
Write 2 to 3 paragraphs aboutONE DDoS attack that occurred in 2016.pdf
 
Why is methyl salicylate not appreciably soluble in waterSoluti.pdf
Why is methyl salicylate not appreciably soluble in waterSoluti.pdfWhy is methyl salicylate not appreciably soluble in waterSoluti.pdf
Why is methyl salicylate not appreciably soluble in waterSoluti.pdf
 
Who are stakeholders Define who they are and then please share what.pdf
Who are stakeholders Define who they are and then please share what.pdfWho are stakeholders Define who they are and then please share what.pdf
Who are stakeholders Define who they are and then please share what.pdf
 
What was the biggest problem with the Articles of Confederation They.pdf
What was the biggest problem with the Articles of Confederation They.pdfWhat was the biggest problem with the Articles of Confederation They.pdf
What was the biggest problem with the Articles of Confederation They.pdf
 
What is UWIN and what does it doSolutionUWin is a software .pdf
What is UWIN and what does it doSolutionUWin is a software .pdfWhat is UWIN and what does it doSolutionUWin is a software .pdf
What is UWIN and what does it doSolutionUWin is a software .pdf
 
What sort of archaeological remains have been discovered on the site.pdf
What sort of archaeological remains have been discovered on the site.pdfWhat sort of archaeological remains have been discovered on the site.pdf
What sort of archaeological remains have been discovered on the site.pdf
 
Link to assignment that I need help with is below httpweb.cse..pdf
Link to assignment that I need help with is below httpweb.cse..pdfLink to assignment that I need help with is below httpweb.cse..pdf
Link to assignment that I need help with is below httpweb.cse..pdf
 
The Food Stamp Program is Americas first line of defense against hu.pdf
The Food Stamp Program is Americas first line of defense against hu.pdfThe Food Stamp Program is Americas first line of defense against hu.pdf
The Food Stamp Program is Americas first line of defense against hu.pdf
 

Recently uploaded

TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 

Recently uploaded (20)

TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 

Help with the following code1. Rewrite to be contained in a vecto.pdf

  • 1. Help with the following code: 1. Rewrite to be contained in a vector object. 2. Using linked lists, redo to handle as many entries as required. 3. Add the ability to add or delete a new entry to the address book. 4. When the program terminates, write the data in the address book to a disk. # include # include # include using namespace std; class addressbook { private: char name[500]; long ph_num; //class addressType :public addressbook char address[500]; int year; int mounth; int day; char gender; int d, Th, y; char M, F, m, f; // char freind[]; public: addressbook(); void setName(); void getName(); void getphone(); long setphone(); void setAddress(); void getAddress(); float getAverage(); int setDay(); void getDay(); int setMounth(); void getMounth();
  • 2. int setYear(); void getYear(); char setGender(); void getGender(); }; addressbook::addressbook() // constructor { name; ph_num = 0; year = 0; mounth = 0; day = 0; } int addressbook::setDay() { cout << " tEnter the day: t" << endl; cin >> d; day = (d >= 1 && d<32) ? d : 0; return day; } int addressbook::setMounth() { cout << " tEnter the mounth: t" << endl; cin >> m; mounth = (Th >= 1 && Th<13) ? Th : 0; return mounth; } int addressbook::setYear() { cout << " tEnter the year : t" << endl; cin >> y; year = (y >= 1 && y<2008) ? y : 0; return year; }
  • 3. void addressbook::getMounth() { cout << mounth << "/"; } void addressbook::getDay() { cout << "tBIRTH DAY : " << day << "/"; } void addressbook::getYear() { cout << year; } char addressbook::setGender() { int flag = 0; cout << " tEnter the gender,(F)for female (M)for male: t"; cin >> gender; while (flag != 1) { if (gender == ('F') || gender == ('M') || gender == ('m') || gender == ('f')) flag = 1; else { cout << "t error.....Try Again t"; cin >> gender; return gender; } } } void addressbook::getGender() { cout << "tGender : " << gender << endl; } void addressbook::getAddress() {
  • 4. cout << "tAddress : " << address << endl; } float addressbook::getAverage() { return 0.0f; } void addressbook::setAddress() { cout << " tEnter the address: t" << endl; gets_s(address); } void addressbook::setName() { cout << " tEnter the name: t" << endl; gets_s(name); } void addressbook::getName() { cout << " tName : " << name << " " << endl; } long addressbook::setphone() { cout << " tEnter the person number: t" << endl; cin >> ph_num; return ph_num; } void addressbook::getphone() { cout << "tPerson # : " << ph_num << endl; } /*class addressType :public addressbook { do that };*/ int main() {
  • 5. int s; cout << " Enter number person max(500): "; cin >> s; addressbook book[10]; for (int i = 1; i<2; i++) { book[i].setName(); book[i].setphone(); book[i].setAddress(); book[i].setDay(); book[i].setMounth(); book[i].setYear(); book[i].setGender(); cout << " *********************************** "; } for (int u = 0; u<2; u++) { book[u].getName(); book[u].getphone(); book[u].getAddress(); book[u].getGender(); book[u].getDay(); book[u].getMounth(); book[u].getYear(); } _getch(); } Solution Question 1 Changes to be made in the code: Instead of: char name[500]; write: vector name(500);
  • 6. similarly, instead of: char address[500]; change it to: vector address(500); and finally change addressbook book[10]; to: vector book(10); You might have figured it out by the changes but for reference, changing an array to vector has to be done by mentioning "vector" followed by the "data_type" inside "<>" and then mentioning the name of the identifier(variable) like in an array and providing its size, but the size has to be inside "()" instead of "[]". Edit1- include the vector header file at the header section as: #include Here is the complete code- # include # include # include #include using namespace std; class addressbook { private: vector name(500); long ph_num; //class addressType :public addressbook vector address(500); int year; int mounth; int day; char gender; int d, Th, y; char M, F, m, f; // char freind[]; public: addressbook(); void setName();
  • 7. void getName(); void getphone(); long setphone(); void setAddress(); void getAddress(); float getAverage(); int setDay(); void getDay(); int setMounth(); void getMounth(); int setYear(); void getYear(); char setGender(); void getGender(); }; addressbook::addressbook() // constructor { name; ph_num = 0; year = 0; mounth = 0; day = 0; } int addressbook::setDay() { cout << " tEnter the day: t" << endl; cin >> d; day = (d >= 1 && d<32) ? d : 0; return day; } int addressbook::setMounth() { cout << " tEnter the mounth: t" << endl; cin >> m;
  • 8. mounth = (Th >= 1 && Th<13) ? Th : 0; return mounth; } int addressbook::setYear() { cout << " tEnter the year : t" << endl; cin >> y; year = (y >= 1 && y<2008) ? y : 0; return year; } void addressbook::getMounth() { cout << mounth << "/"; } void addressbook::getDay() { cout << "tBIRTH DAY : " << day << "/"; } void addressbook::getYear() { cout << year; } char addressbook::setGender() { int flag = 0; cout << " tEnter the gender,(F)for female (M)for male: t"; cin >> gender; while (flag != 1) { if (gender == ('F') || gender == ('M') || gender == ('m') || gender == ('f')) flag = 1; else { cout << "t error.....Try Again t"; cin >> gender; return gender;
  • 9. } } } void addressbook::getGender() { cout << "tGender : " << gender << endl; } void addressbook::getAddress() { cout << "tAddress : " << address << endl; } float addressbook::getAverage() { return 0.0f; } void addressbook::setAddress() { cout << " tEnter the address: t" << endl; gets_s(address); } void addressbook::setName() { cout << " tEnter the name: t" << endl; gets_s(name); } void addressbook::getName() { cout << " tName : " << name << " " << endl; } long addressbook::setphone() { cout << " tEnter the person number: t" << endl; cin >> ph_num; return ph_num; }
  • 10. void addressbook::getphone() { cout << "tPerson # : " << ph_num << endl; } /*class addressType :public addressbook { do that };*/ int main() { int s; cout << " Enter number person max(500): "; cin >> s; vector book(10); for (int i = 1; i<2; i++) { book[i].setName(); book[i].setphone(); book[i].setAddress(); book[i].setDay(); book[i].setMounth(); book[i].setYear(); book[i].setGender(); cout << " *********************************** "; } for (int u = 0; u<2; u++) { book[u].getName(); book[u].getphone(); book[u].getAddress(); book[u].getGender(); book[u].getDay(); book[u].getMounth(); book[u].getYear(); } _getch();
  • 11. }