Question: 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

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. Output "Average participant age: " followed by the average age of all the Participant objects.

Ex: If the input is:

5 Eli 89 Jan 57 Ari 68 Noa 72 Jen 11

then the output is:

Average participant age: 59.4

Note: The vector has at least one element.

#include #include using namespace std;

class Participant { public: void SetDetails(string newName, int newAge); int GetAge() const; private: string name; int age; };

void Participant::SetDetails(string newName, int newAge) { name = newName; age = newAge; }

int Participant::GetAge() const { return age; }

int main() { int participantCount; unsigned int i; vector participantList; Participant currParticipant; string currName; int currAge; double sumAge;

cin >> participantCount; for (i = 0; i < participantCount; ++i) { cin >> currName; cin >> currAge; currParticipant.SetDetails(currName, currAge); participantList.push_back(currParticipant); } sumAge = 0.0;

/* Your code goes here */

return 0; }

c++ and please please make it correct

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 Databases Questions!