This is what I need to do:

Use a single-subscripted array to solve the following problem: A company pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9% of their gross sales for that week. For example, a salesperson who grosses $5000 in sales in a week receives $200 plus 9% of $5000 or a total of $650. Write a program (using an array of counters) that determines how many of the salespeople earned salaries in each of the following ranges (assume that each salespersonâ€™s salary is truncated to an integer amount):

a) $200-$299

b) $300-$399

c) $400-$499

d) $500-$599

e) $600-$699

f) $700-$799

g) $800-$899

h) $900-$999

i) $1000 and over

Summarize the results in tabular format

This is what I've got:

```
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
#include <iomanip>
void displayResults( );
int main()
{
int sales;
double salary;
int counter[ 9 ] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
cout << "Enter a sales amount: (negative to end)";
cin >> sales;
while (sales > 0){
salary = (sales * .09) + 200;
if ( (salary >= 200) && (salary < 300) )
++counter[ 0 ];
else if ( (salary >= 300) && (salary < 400) )
++counter[ 1 ];
else if ( (salary >= 400) && (salary < 500) )
++counter[ 2 ];
else if ( (salary >= 500) && (salary < 600) )
++counter[ 3 ];
else if ( (salary >= 600) && (salary < 700) )
++counter[ 4 ];
else if ( (salary >= 700) && (salary < 800) )
++counter[ 5 ];
else if ( (salary >= 800) && (salary < 900) )
++counter[ 6 ];
else if ( (salary >= 900) && (salary < 1000) )
++counter[ 7 ];
else
++counter[ 8 ];
cout << "Enter a sales amount: (negative to end)";
cin >> sales;
}
displayResults();
system("pause");
return 0;
}
void displayResults( )
{
int counter[ 9 ];
cout << " Range Number" << endl;
cout << "$200 - $299\t " << counter[ 0 ] << endl;
cout << "$300 - $399\t " << counter[ 1 ] << endl;
cout << "$400 - $499\t " << counter[ 2 ] << endl;
cout << "$500 - $599\t " << counter[ 3 ] << endl;
cout << "$600 - $699\t " << counter[ 4 ] << endl;
cout << "$700 - $799\t " << counter[ 5 ] << endl;
cout << "$800 - $899\t " << counter[ 6 ] << endl;
cout << "$900 - $999\t " << counter[ 7 ] << endl;
cout << "Over $1000 \t " << counter[ 8 ] << endl;
}
```

I am fairly new to C++, and am not sure how to fix it. I have used QBasic and C before, but not extensively. The program sort of works...but it doesn't display the proper results in the function. If I put a regular cout << counter[whatever]; into the main function, it displays the proper results...any ideas how I can transfer the correct results into the function? I have read a lot about passing arrays into functions, but can't figure out what exactly to add to my program to make it do what it is supposed to. Any help would be greatly appreciated, thank you! =)

~TheSilverFox