Question: Name FA 2 0 2 4 The Person class is depicted in Figure 1 . As indicated in the class diagram, each person object contains

Name
FA2024
The Person class is depicted in Figure 1.
As indicated in the class diagram, each person object contains the PRIVATE fields ID, name, and age. The data members ID and age are integers, and the name is a string. The class includes public mutators, accessors, constructors, and a toString() user-defined function that returns a string indicating the fields held in the object (see slides chapter 13).
Write an app to implement the Person class. The app will create a database of Person objects. The database should be represented as vector Person >db.
The data to create the vector is stored in the file c:/temp/springfieldPeople.txt (see Figure 2). Each file record consists of id, name, age, and data (Caution - Not each of those fields will be used to make a person instance.)
Your app must include a function called printYoungPeople. This function will identify and display the persons whose age is less than the calculated average age of the sample.
Figure 1. Class Diagram
The function's header is provided below.
void printYoungPeople(vector Person >&db)
For instance, if you calculate the average age and it produces a value such as 40, the printYoungPeople function will display those individuals strictly under 40. Displaying the selected person objects must be done using the toString method.
Additional Specs.
Do not use features outside of the material covered in the text and the lectures.
Figure 2. File springfieldPeople.txt
Each record contains ID, name, age, and data.
100,Homer Simpson,39, data100
105,Marge Simpson,36,data 105
110,Bart Simpson, 10, datal10
115,Lisa Simpson,8,data115
120,Maggie Simpson, 1,data 120
125,Abraham Simpson,83, data 125
130,Ned Flanders,60,data130
135,Maude Flanders,58, data135
140,Milhouse Van Houten, 10, data140
145,Nelson Muntz, 12, data 145
150,Ralph Wiggum,8,data 50
155,Seymour Skinner,44,data155
160,Edna Krabappel,41,data160
165,Apu Nahasapeemapetilon,45,data 165
170,Moe Szyslak,50,data170
175,Barney Gumble, 40, data175
180,Krusty the Clown, 55,datal 80
185,Clancy Wiggum,45, data185
190, Waylon Smithers, 40, data 190
195,Montgomery Burns, 104,data195
Figure 3. Sample Output
Name FA 2 0 2 4 The Person class is depicted in

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