Question: Write a program that reads Person information from a file, create a Person object and store the information read into this object. Once the information

Write a program that reads Person information from a file, create a Person object and store the information read into this object. Once the information is stored in Persons array, print the information and sort it based on person age using Selection sort and show the result.
main.cpp
Reads information from groups.txt file provided and store the data into Persons array.
Displays the information of Person using overloaded output stream operator <<.
Sorts the Persons array based on the age, using Selection Sort.
Displays the information of Person using overloaded output stream operator << after sorting.
Before:
Person Name: Emma Jones, Age: 1, Income: 0
Person Name: Noah Jackson, Age: 50, Income: 25000
Person Name: Olivia Hines, Age: 21, Income: 40000
Person Name: Liam Williamson, Age: 47, Income: 34000
Person Name: Sophia Smith, Age: 13, Income: 0
Person Name: Mason Jones, Age: 34, Income: 23000.5
Person Name: Ava Davis, Age: 41, Income: 56000
Person Name: Jacob Moore, Age: 14, Income: 0
Person Name: Isabella Thomas, Age: 5, Income: 0
Person Name: William White, Age: 15, Income: 0
Person Name: Mia Jackson, Age: 6, Income: 0
Person Name: Ethan Harris, Age: 21, Income: 78000.5
Person Name: Abigail James, Age: 71, Income: 15000
Person Name: Emily Alexander, Age: 18, Income: 0
Person Name: Charlotte Martin, Age: 91, Income: 10000
Person Name: Michael Garcia, Age: 34, Income: 56000
Person Name: Benjamin Harper, Age: 10, Income: 0
After:
Person Name: Emma Jones, Age: 1, Income: 0
Person Name: Isabella Thomas, Age: 5, Income: 0
Person Name: Mia Jackson, Age: 6, Income: 0
Person Name: Benjamin Harper, Age: 10, Income: 0
Person Name: Sophia Smith, Age: 13, Income: 0
Person Name: Jacob Moore, Age: 14, Income: 0
Person Name: William White, Age: 15, Income: 0
Person Name: Emily Alexander, Age: 18, Income: 0
Person Name: Olivia Hines, Age: 21, Income: 40000
Person Name: Ethan Harris, Age: 21, Income: 78000.5
Person Name: Mason Jones, Age: 34, Income: 23000.5
Person Name: Michael Garcia, Age: 34, Income: 56000
Person Name: Ava Davis, Age: 41, Income: 56000
Person Name: Liam Williamson, Age: 47, Income: 34000
Person Name: Noah Jackson, Age: 50, Income: 25000
Person Name: Abigail James, Age: 71, Income: 15000
Person Name: Charlotte Martin, Age: 91, Income: 10000
Class Description
Person.h
Constructor: Assigns age, first name, last name, salary in the same order.
operator< function: You need to overload < operator to return true if age of lhs person is less than age of rhs person else false.
operator<< function: Prints the person as specified in sample output below.
Person p1(23,"A","a",10000
cout<

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!