(Salesperson Salary Ranges) Use a one-dimensional array to solve the following problem. A company pays its salespeople on a commission basis. The salespeople each receive $200 per week plus 9 percent of their gross sales for that week. For example, a salesperson who grosses $5000 in sales in a week receives $200 plus 9 percent 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 follow- ing 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

```
#include
#include
using namespace std;

void wages( int [] ); // function prototype
void display( const int [] ); // function prototype

int main()
{
int salaries[ 11 ] = {}; // array to hold salaries

cout << fixed << showpoint;
wages( salaries ); // calculate wages
display( salaries ); // display ranges of wages
} // end main
// function that asks user to input gross sales
// and calculates employee salary based on input
void wages( int money[] )
{
double sales; // holds employee gross sales
double i = 0.09; // 9%, used for calculating salary

// prompt user for gross sales and store it in sales
cout << "Enter employee gross sales (-1 to end): ";
cin >> sales;

// calculate salary based on sales
// and prompt user for another employee sales amount
while ( sales != -1 )
{
double salary = 200.0 + sales * i;
cout << setprecision( 2 ) << "Employee Commission is $"
< salary << '\n';

int x = static_cast< int > ( salary ) / 100;
money[ ( x < 10 ? x : 10 ) ]++;

cout << "\nEnter employee gross sales (-1 to end): ";
cin >> sales;
} // end while
} // end function wages

// function that displays table of salary ranges
// and number of employees in each range
void display( const int dollars[] )
{
// display table of ranges and employees in each range
cout << "Employees in the range:";

for ( int i = 2; i < 10; i++ )
cout << "\n$" << i << "00-$" << i << "99 : " << dollars[ i ];

cout << "\nOver $1000: " << dollars[ 10 ] << endl;
} // end function display
```

Computer Science & Information Technology

You might also like to view...

Provide a user’s requirements specification for the EasyDrive School of Motoring case study documented in Appendix B.2.

What will be an ideal response?

Computer Science & Information Technology

This is a drawing of a network device or cabling.

What will be an ideal response?

Computer Science & Information Technology