SlideShare uma empresa Scribd logo
1 de 2
Baixar para ler offline
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;
}

Mais conteúdo relacionado

Semelhante a The program first reads integer participantCount from input.pdf

ANSHUL RANA - PROGRAM FILE.pptx
ANSHUL RANA - PROGRAM FILE.pptxANSHUL RANA - PROGRAM FILE.pptx
ANSHUL RANA - PROGRAM FILE.pptx
jeyel85227
 
Chapter2pp
Chapter2ppChapter2pp
Chapter2pp
J. C.
 
solution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdf
solution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdfsolution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdf
solution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdf
parthp5150s
 
Digits.javapackage week04;import java.util.Scanner; public cla.pdf
Digits.javapackage week04;import java.util.Scanner; public cla.pdfDigits.javapackage week04;import java.util.Scanner; public cla.pdf
Digits.javapackage week04;import java.util.Scanner; public cla.pdf
annapurnnatextailes
 
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdfNeed done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
info114
 
Create a C program which performs the addition of two comple.pdf
Create a C program which performs the addition of two comple.pdfCreate a C program which performs the addition of two comple.pdf
Create a C program which performs the addition of two comple.pdf
devangmittal4
 

Semelhante a The program first reads integer participantCount from input.pdf (20)

Programming in C Lab
Programming in C LabProgramming in C Lab
Programming in C Lab
 
python_lab_manual_final (1).pdf
python_lab_manual_final (1).pdfpython_lab_manual_final (1).pdf
python_lab_manual_final (1).pdf
 
ANSHUL RANA - PROGRAM FILE.pptx
ANSHUL RANA - PROGRAM FILE.pptxANSHUL RANA - PROGRAM FILE.pptx
ANSHUL RANA - PROGRAM FILE.pptx
 
Chapter2pp
Chapter2ppChapter2pp
Chapter2pp
 
Compose Camp - Intro.pdf.pdf
Compose Camp - Intro.pdf.pdfCompose Camp - Intro.pdf.pdf
Compose Camp - Intro.pdf.pdf
 
B.Com 1year Lab programs
B.Com 1year Lab programsB.Com 1year Lab programs
B.Com 1year Lab programs
 
solution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdf
solution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdfsolution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdf
solution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdf
 
Csphtp1 07
Csphtp1 07Csphtp1 07
Csphtp1 07
 
Digits.javapackage week04;import java.util.Scanner; public cla.pdf
Digits.javapackage week04;import java.util.Scanner; public cla.pdfDigits.javapackage week04;import java.util.Scanner; public cla.pdf
Digits.javapackage week04;import java.util.Scanner; public cla.pdf
 
Python.pptx
Python.pptxPython.pptx
Python.pptx
 
Project: Call Center Management
Project: Call Center ManagementProject: Call Center Management
Project: Call Center Management
 
Programming For As Comp
Programming For As CompProgramming For As Comp
Programming For As Comp
 
Programming For As Comp
Programming For As CompProgramming For As Comp
Programming For As Comp
 
Oot practical
Oot practicalOot practical
Oot practical
 
Linux_C_LabBasics.ppt
Linux_C_LabBasics.pptLinux_C_LabBasics.ppt
Linux_C_LabBasics.ppt
 
Java practical(baca sem v)
Java practical(baca sem v)Java practical(baca sem v)
Java practical(baca sem v)
 
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdfNeed done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
 
OOP program questions with answers
OOP program questions with answersOOP program questions with answers
OOP program questions with answers
 
PYTHON PROGRAMS
PYTHON PROGRAMSPYTHON PROGRAMS
PYTHON PROGRAMS
 
Create a C program which performs the addition of two comple.pdf
Create a C program which performs the addition of two comple.pdfCreate a C program which performs the addition of two comple.pdf
Create a C program which performs the addition of two comple.pdf
 

Mais de adithvrc

The Rings of Saturn There are many planetary subsystems with.pdf
The Rings of Saturn There are many planetary subsystems with.pdfThe Rings of Saturn There are many planetary subsystems with.pdf
The Rings of Saturn There are many planetary subsystems with.pdf
adithvrc
 
The Protocol We present the protocol sequentially though if.pdf
The Protocol We present the protocol sequentially though if.pdfThe Protocol We present the protocol sequentially though if.pdf
The Protocol We present the protocol sequentially though if.pdf
adithvrc
 
The route of the planned Galway City outer bypass is entirel.pdf
The route of the planned Galway City outer bypass is entirel.pdfThe route of the planned Galway City outer bypass is entirel.pdf
The route of the planned Galway City outer bypass is entirel.pdf
adithvrc
 
The protocol will use the following building blocks The Inn.pdf
The protocol will use the following building blocks The Inn.pdfThe protocol will use the following building blocks The Inn.pdf
The protocol will use the following building blocks The Inn.pdf
adithvrc
 
The purpose of this project is to develop a code which will .pdf
The purpose of this project is to develop a code which will .pdfThe purpose of this project is to develop a code which will .pdf
The purpose of this project is to develop a code which will .pdf
adithvrc
 

Mais de adithvrc (20)

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

Último

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 

Último (20)

FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.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
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
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
 
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
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
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
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 

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; }