SlideShare a Scribd company logo
The program first reads integer participantCount from input, representing the number of pairs of
inputs to be read. Each pair has a string and an integer. One Participant object is created for each
pair and added to vector participantList. Write the PrintParticipantsInRange() function in the
Appointments class using Print() to output all the Participant objects with age between 28 and 78,
both inclusive.
Ex: If the input is:
4 Eve 78 Dan 12 Ari 28 Eli 21
then the output is:
Participant: Eve, Age: 78 Participant: Ari, Age: 28
Note: The vector has at least one element.
CODE:
#include <iostream>
#include <vector>
using namespace std;
class Participant {
public:
void SetDetails(string newName, int newAge);
int GetAge() const;
void Print() const;
private:
string name;
int age;
};
void Participant::SetDetails(string newName, int newAge) {
name = newName;
age = newAge;
}
int Participant::GetAge() const {
return age;
}
void Participant::Print() const {
cout << "Participant: " << name << ", Age: " << age << endl;
}
class Appointments {
public:
void InputParticipants();
void PrintParticipantsInRange();
private:
vector<Participant> participantList;
};
void Appointments::InputParticipants() {
int participantCount;
unsigned int i;
Participant currParticipant;
string currName;
int currAge;
cin >> participantCount;
for (i = 0; i < participantCount; ++i) {
cin >> currName;
cin >> currAge;
currParticipant.SetDetails(currName, currAge);
participantList.push_back(currParticipant);
}
}
/*write code here */
int main() {
Appointments appointments;
appointments.InputParticipants();
appointments.PrintParticipantsInRange();
return 0;
}

More Related Content

PDF
#include iostream #include fstream #include vector #incl.pdf
PDF
Ch 4
DOCX
main-cpp file #include -iostream- #include -vector- #include -Date-h.docx
DOCX
Cs pritical file
DOCX
Brinkley – Over HereChanges during WWII led to an .docx
PDF
Program 1 (Practicing an example of function using call by referenc.pdf
PPT
OBJECTS IN Object Oriented Programming .ppt
DOCX
Assignement of programming & problem solving u.s ass.(1)
#include iostream #include fstream #include vector #incl.pdf
Ch 4
main-cpp file #include -iostream- #include -vector- #include -Date-h.docx
Cs pritical file
Brinkley – Over HereChanges during WWII led to an .docx
Program 1 (Practicing an example of function using call by referenc.pdf
OBJECTS IN Object Oriented Programming .ppt
Assignement of programming & problem solving u.s ass.(1)

Similar to The program first reads integer participantCount from input.pdf (20)

PDF
Header #include -string- #include -vector- #include -iostream- using.pdf
PDF
#include -string- #include -string- #include -vector- #include -iostre (1).pdf
DOCX
OOP program questions with answers
PPT
2621008 - C++ 4
PPTX
C++ Object Oriented Programming Lecture Slides for Students
PDF
Classes and objects
DOCX
#include -iostream- #include -vector- #include -Date-h- #include -Pers.docx
DOCX
#include -iostream- #include -vector- #include -Date-h- #include -Pers.docx
PDF
Computer science solution - programming - big c plus plus
PDF
Declaring friend function with inline code
PDF
struct procedure {    Date dateOfProcedure;    int procedureID.pdf
DOCX
Assignement of programming & problem solving
PDF
C++ practical
PDF
computer science sample papers 2
DOC
Pads lab manual final
PDF
I have the following code and I need to know why I am receiving the .pdf
PPTX
Assignement of c++
DOCX
Pratik Bakane C++
DOCX
Classes(or Libraries)#include #include #include #include.docx
PDF
Rajeev oops 2nd march
Header #include -string- #include -vector- #include -iostream- using.pdf
#include -string- #include -string- #include -vector- #include -iostre (1).pdf
OOP program questions with answers
2621008 - C++ 4
C++ Object Oriented Programming Lecture Slides for Students
Classes and objects
#include -iostream- #include -vector- #include -Date-h- #include -Pers.docx
#include -iostream- #include -vector- #include -Date-h- #include -Pers.docx
Computer science solution - programming - big c plus plus
Declaring friend function with inline code
struct procedure {    Date dateOfProcedure;    int procedureID.pdf
Assignement of programming & problem solving
C++ practical
computer science sample papers 2
Pads lab manual final
I have the following code and I need to know why I am receiving the .pdf
Assignement of c++
Pratik Bakane C++
Classes(or Libraries)#include #include #include #include.docx
Rajeev oops 2nd march
Ad

More from adithvrc (20)

PDF
The production function of a restaurant includes items such .pdf
PDF
The parent Rubidium87 has a halflife of 50 billion years .pdf
PDF
The portfolios identified below are being considered for inv.pdf
PDF
The Rings of Saturn There are many planetary subsystems with.pdf
PDF
The residents living in the community of Joy has a big pro.pdf
PDF
The Protocol We present the protocol sequentially though if.pdf
PDF
The route of the planned Galway City outer bypass is entirel.pdf
PDF
The riskiness of publicly traded bond issues is rated by ind.pdf
PDF
The rate of photosynthesis as indicated by oxygen productio.pdf
PDF
The random variable Y with a density function given by fy.pdf
PDF
The program below is written in C++ language using an Object.pdf
PDF
The probability that a patient recovers from a stomach disea.pdf
PDF
The protocol will use the following building blocks The Inn.pdf
PDF
The purpose of this project is to develop a code which will .pdf
PDF
The questionnaires prescreening tools and screening script.pdf
PDF
The Public Company Accounting Oversishit Board PCAOB Whs c.pdf
PDF
The Pulfrich effect demonstrates one way in which the human .pdf
PDF
The purpose of the decision analysis phase is to Identify .pdf
PDF
The previous year had an unemployment rate of 108 nominal.pdf
PDF
The price of a stock fluctuates between 43 and 560 H the .pdf
The production function of a restaurant includes items such .pdf
The parent Rubidium87 has a halflife of 50 billion years .pdf
The portfolios identified below are being considered for inv.pdf
The Rings of Saturn There are many planetary subsystems with.pdf
The residents living in the community of Joy has a big pro.pdf
The Protocol We present the protocol sequentially though if.pdf
The route of the planned Galway City outer bypass is entirel.pdf
The riskiness of publicly traded bond issues is rated by ind.pdf
The rate of photosynthesis as indicated by oxygen productio.pdf
The random variable Y with a density function given by fy.pdf
The program below is written in C++ language using an Object.pdf
The probability that a patient recovers from a stomach disea.pdf
The protocol will use the following building blocks The Inn.pdf
The purpose of this project is to develop a code which will .pdf
The questionnaires prescreening tools and screening script.pdf
The Public Company Accounting Oversishit Board PCAOB Whs c.pdf
The Pulfrich effect demonstrates one way in which the human .pdf
The purpose of the decision analysis phase is to Identify .pdf
The previous year had an unemployment rate of 108 nominal.pdf
The price of a stock fluctuates between 43 and 560 H the .pdf
Ad

Recently uploaded (20)

PPTX
20th Century Theater, Methods, History.pptx
PPTX
Virtual and Augmented Reality in Current Scenario
PDF
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf
PDF
AI-driven educational solutions for real-life interventions in the Philippine...
PDF
advance database management system book.pdf
PDF
FORM 1 BIOLOGY MIND MAPS and their schemes
PDF
1.3 FINAL REVISED K-10 PE and Health CG 2023 Grades 4-10 (1).pdf
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
PDF
IGGE1 Understanding the Self1234567891011
PDF
Τίμαιος είναι φιλοσοφικός διάλογος του Πλάτωνα
PDF
Practical Manual AGRO-233 Principles and Practices of Natural Farming
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
Hazard Identification & Risk Assessment .pdf
PPTX
A powerpoint presentation on the Revised K-10 Science Shaping Paper
PDF
LDMMIA Reiki Yoga Finals Review Spring Summer
PPTX
History, Philosophy and sociology of education (1).pptx
PPTX
TNA_Presentation-1-Final(SAVE)) (1).pptx
PDF
Trump Administration's workforce development strategy
PDF
CISA (Certified Information Systems Auditor) Domain-Wise Summary.pdf
PPTX
Share_Module_2_Power_conflict_and_negotiation.pptx
20th Century Theater, Methods, History.pptx
Virtual and Augmented Reality in Current Scenario
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf
AI-driven educational solutions for real-life interventions in the Philippine...
advance database management system book.pdf
FORM 1 BIOLOGY MIND MAPS and their schemes
1.3 FINAL REVISED K-10 PE and Health CG 2023 Grades 4-10 (1).pdf
Paper A Mock Exam 9_ Attempt review.pdf.
IGGE1 Understanding the Self1234567891011
Τίμαιος είναι φιλοσοφικός διάλογος του Πλάτωνα
Practical Manual AGRO-233 Principles and Practices of Natural Farming
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Hazard Identification & Risk Assessment .pdf
A powerpoint presentation on the Revised K-10 Science Shaping Paper
LDMMIA Reiki Yoga Finals Review Spring Summer
History, Philosophy and sociology of education (1).pptx
TNA_Presentation-1-Final(SAVE)) (1).pptx
Trump Administration's workforce development strategy
CISA (Certified Information Systems Auditor) Domain-Wise Summary.pdf
Share_Module_2_Power_conflict_and_negotiation.pptx

The program first reads integer participantCount from input.pdf

  • 1. The program first reads integer participantCount from input, representing the number of pairs of inputs to be read. Each pair has a string and an integer. One Participant object is created for each pair and added to vector participantList. Write the PrintParticipantsInRange() function in the Appointments class using Print() to output all the Participant objects with age between 28 and 78, both inclusive. Ex: If the input is: 4 Eve 78 Dan 12 Ari 28 Eli 21 then the output is: Participant: Eve, Age: 78 Participant: Ari, Age: 28 Note: The vector has at least one element. CODE: #include <iostream> #include <vector> using namespace std; class Participant { public: void SetDetails(string newName, int newAge); int GetAge() const; void Print() const; private: string name; int age; }; void Participant::SetDetails(string newName, int newAge) { name = newName; age = newAge; } int Participant::GetAge() const { return age; } void Participant::Print() const { cout << "Participant: " << name << ", Age: " << age << endl; } class Appointments { public: void InputParticipants(); void PrintParticipantsInRange(); private: vector<Participant> participantList; }; void Appointments::InputParticipants() { int participantCount;
  • 2. unsigned int i; Participant currParticipant; string currName; int currAge; cin >> participantCount; for (i = 0; i < participantCount; ++i) { cin >> currName; cin >> currAge; currParticipant.SetDetails(currName, currAge); participantList.push_back(currParticipant); } } /*write code here */ int main() { Appointments appointments; appointments.InputParticipants(); appointments.PrintParticipantsInRange(); return 0; }