#include #include #include using namespace std; struct Person { string name; int age; float gpa; }; void CopyData(string filename,Person a[]) { std::ifstream infile(filename); string temp_name; int temp_age; float temp_gpa; int i=0; while(infile >> temp_name >> temp_age >> temp_gpa) { a[i].name = temp_name; a[i].age = temp_age; a[i].gpa = temp_gpa; i++; } } void Display(Person a[]) { int i = 0; cout << \"Name of all the teenagers whose age is in between 13 and 19 : \ \"; while(i<6) { if(a[i].age>=13 && a[i].age<=19) cout << a[i].name << endl; i++; } cout << endl; } void ComputeAverage(Person a[],float &AgeAve,float &GpaAve) { int i=0; float ageSum = 0,gpaSum = 0; while(i<6) { ageSum += a[i].age; gpaSum += a[i].gpa; i++; } AgeAve = ageSum/6.0; GpaAve = gpaSum/6.0; } void Display(float AgeAve,float GpaAve) { cout << \"Age Average is : \" << AgeAve << endl; cout << \"GPA Average is : \" << GpaAve << endl; cout << endl; } void Display(Person a[],float GpaAve) { int i = 0; cout << \"Name of all the teenagers whose gpa is greater than average gpa : \ \"; while(i<6) { if(a[i].gpa>GpaAve) cout << a[i].name << \" \" << a[i].age << \" \" << a[i].gpa << endl; i++; } cout << endl; } int main() { Person a[6]; string filename = \"/Users/deepanshugupta/Documents/chegg/chegg/data.txt\"; CopyData(filename,a); Display(a); float AgeAve = 0.0 ,GpaAve = 0.0; ComputeAverage(a, AgeAve, GpaAve); Display(AgeAve,GpaAve); cout << endl; Display(a,GpaAve); cout << endl; return 0; } Solution #include #include #include using namespace std; struct Person { string name; int age; float gpa; }; void CopyData(string filename,Person a[]) { std::ifstream infile(filename); string temp_name; int temp_age; float temp_gpa; int i=0; while(infile >> temp_name >> temp_age >> temp_gpa) { a[i].name = temp_name; a[i].age = temp_age; a[i].gpa = temp_gpa; i++; } } void Display(Person a[]) { int i = 0; cout << \"Name of all the teenagers whose age is in between 13 and 19 : \ \"; while(i<6) { if(a[i].age>=13 && a[i].age<=19) cout << a[i].name << endl; i++; } cout << endl; } void ComputeAverage(Person a[],float &AgeAve,float &GpaAve) { int i=0; float ageSum = 0,gpaSum = 0; while(i<6) { ageSum += a[i].age; gpaSum += a[i].gpa; i++; } AgeAve = ageSum/6.0; GpaAve = gpaSum/6.0; } void Display(float AgeAve,float GpaAve) { cout << \"Age Average is : \" << AgeAve << endl; cout << \"GPA Average is : \" << GpaAve << endl; cout << endl; } void Display(Person a[],float GpaAve) { int i = 0; cout << \"Name of all the teenagers whose gpa is greater than average gpa : \ \"; while(i<6) { if(a[i].gpa>GpaAve) cout << a[i].name << \" \" << a[i].age << \" \" << a[i].gpa << endl; i++; } cout << endl; } int main() { Person a[6]; string filename = \"/Users/deepanshugupta/Documents/chegg/chegg/data.txt\"; CopyData(filename,a); Display(a); float AgeAve = 0.0 ,GpaAve = 0.0; ComputeAverage(a, AgeAve, GpaAve); Display(AgeAve,GpaAve); cout << endl; Display(a,GpaAve); cout << endl; return 0; }.