Answer:
see explaination
Step-by-step explanation:
#include <iostream>
using namespace std;
void display (string* name, double* purchase, int n)
{
cout<<"Name Purchase"<<endl;
cout<<"------------------------"<<endl<<endl;
for(int i=0;i<n;i++)
{
cout<<name[i]<<" "<<purchase[i]<<endl;
}
}
double calculate(double* purchase,int n)
{
double avg, sum=0;
for(int i=0;i<n;i++)
{
sum=sum+purchase[i];
}
avg=sum/n;
return avg;
}
int main()
{
int n;
cout<<"How many customer will you enter? "<<endl;
cin>>n;
string *name=new string[n];
double *purchase=new double[n];
for(int i=0;i<n;i++)
{
cout<<"Enter the customer"<<i+1<<"'s name: "<<endl;
cin>>name[i];
cout<<"Enter that customer's purchase: "<<endl;
cin>>purchase[i];
}
display(name, purchase,n);
double avg=calculate(purchase,n);
cout<<"Average purchase: "<<avg<<endl;
}
See attachment for the screenshot