Question: In C + + PLEASE The program first reads integer memberCount from input, representing the number of pairs of inputs to be read. Each pair

In C++ PLEASE
The program first reads integer memberCount from input, representing the number of pairs of inputs to be read. Each pair has a
string and an integer, representing the member's name and age, respectively. One Member object is created for each pair and
added to vector memberList. Write the FindAverageMemberAge() function in the Appointments class to return the average age of
all the Member objects as an integer.
Ex: If the input is:
4
Pat 72 Noa 90 Ada 30 Eli 80
then the output is:
Average member age: 68
Note: The ArrayList has at least one element. #include
#include
using namespace std;
class Member {
public:
void SetNameAndAge(string newName, int newAge);
int GetAge() const;
private:
string name;
int age;
};
void Member::SetNameAndAge(string newName, int newAge){
name = newName;
age = newAge;
}
int Member::GetAge() const {
return age;
}
class Appointments {
public:
void InputMembers();
int FindAverageMemberAge();
private:
vector memberList;
};
void Appointments::InputMembers(){
Member currMember;
string currName;
int currAge;
int memberCount;
unsigned int i;
cin >> memberCount;
for (i =0; i memberCount; ++i){
cin >> currName;
cin >> currAge;
currMember.SetNameAndAge(currName, currAge);
memberList.push_back(currMember);
}
}
/* Your code goes here */
int main(){
Appointments appointments;
appointments.InputMembers();
cout "Average member age: " appointments.FindAverageMemberAge() endl;
return 0;
}
In C + + PLEASE The program first reads integer

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!