Need help to fix errors, I know int a[] should be specified but not sure how to.
#include <iostream>
using namespace std;
class TWO
{
private: int age[5];
public:
//read data into array
void ReadData(int age[], int n);
//member to return the average of data in array age of object p
friend int FindAverage(TWO p);
//member to find and return the max and min age
void FindMaxMin(int &maxAge, int& minAge, int age[], int n);
//display ages > age average
void DisplayAboveAverage(int ageAve, int age[], int n);
//display the max and min ages
void DisplayMaxMinAge(int maxAge, int minAge, int age[], int n);
//release all memory used by objects
~TWO() {}
};
int main()
{
int a[]; int n;
int maxAge;
int minAge;
int ageAve;
TWO x;
x.ReadData(a[],n);
FindAverage(x);
x.FindMaxMin(maxAge,minAge);
x.DisplayAboveAverage(ageAve);
x.DisplayMaxMinAge(maxAge, minAge);
return 0;
}
// class functions
void TWO :: ReadData(int x[], int n)
{
for(int i = 0; i < 5; ++i)
{ cout << "Enter 5 ages: ";
cin >> x[i];
}
}
void FindAverage(TWO p, int x[], int n)
{ int total = 0;
for(int i = 0; i < 5; ++i)
{
total += x[i];
}
}
void TWO :: FindMaxMin(int &maxAge, int& minAge, int x[], int n)
{
int maxAge = x[0];
for(int i = 0; i < 5; ++i)
if(maxAge < x[i])
maxAge = x[1];
int minAge = x[0];
for(int i = 0; i < 5; ++i)
if(minAge > x[i])
minAge = x[3];
}
void TWO :: DisplayAboveAverage(int ageAve, int x[], int n)
{
int total = 0;
for(int i = 0; i < 5; ++i)
{
total += x[i];
if(ageAve > total)
cout <<
}
}
void TWO :: DisplayMaxMinAge(int maxAge, int minAge, int x[], int n)
{
int maxAge = x[0];
for(int i = 0; i < 5; ++i)
if(maxAge < x[i])
cout << "Maximum age is " << x[1];
int minAge = x[0];
for(int i = 0; i < 5; ++i)
if(minAge > x[i])
cout << x[3];
}
Output should look like this:
Enter 5 ages: 22 27 19 17 25
Ages above average: 27 25
Maximum age is 25
Minimum age is 17