I have taken the crap from your source so that the problem is now easily highlighted. fix it yourself.
Code:
//Alicia Harris
//Open Lab 7
//CSIS 240
#include <iostream>
#include <iomanip>
using namespace std;
//function prototype
double find_ave_bal(int, int);
//main function
int main ()
{
int n, j;
int ID [100] = {0};
int bal [100] = {0};
int num_bal;
double ave_bal;
double sum_bal;
//Loop to input the ID and balance
for (n = 0; n < 100; ++n) // this loop has no ending brace FIXME
{
cout<<"Please enter the account ID and account balance, -1 to to stop: "<<endl;
cin>>ID[j]>>bal[n];
if (ID[j] < 1000 || ID[j] > 9999)
{
cout<<"Invalid ID, please reenter: "<<endl;
}
if (bal[n] > 10000)
{
cout<<"Invalid Balance, please reenter: "<<endl;
}
cout<<"ID Number"<<setw(16)<<"Balance"<<setw(20)<<"Difference from Average"<<endl;
for ( ID[j] = 0; ID[j] < n; ID[j] = ID[j] + 1)
{
cout<<setw(4)<<ID [j]<<setprecision(2)
<<setiosflags(ios::fixed | ios::showpoint)
<<setw(16)<<bal<<setw(20)<<setprecision(2)
<<setiosflags(ios::fixed | ios::showpoint)
<<find_ave_bal (ID [j], num_bal)<<endl;
}
return 0;
}
double find_ave_bal(int ID [], int num_bal)
{
double subtotal = 0;
double total;
for (int j = 0; j < num_bal; j++)
subtotal += ID [j];
total = subtotal / num_bal;
return total;
}