(Salesperson Salary Ranges with vector) Use a vector of integers to solve the problem de- scribed in Exercise 6.10.

What will be an ideal response?


```
#include
#include
#include
using namespace std;

void wages( vector< int > & ); // function prototype
void display( const vector< int > & ); // function prototype

int main()
{
vector< int > salaries( 11 ); // array to hold salaries

cout << fixed << showpoint;
wages( salaries ); // calculate wages
display( salaries ); // display ranges of wages
return 0; // indicates successful termination
} // end main

// function that asks user to input gross sales
// and calculates employee salary based on input
void wages( vector< 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 vector< 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
```
Enter employee gross sales (-1 to end): 10000
Employee Commission is $1100.00
Enter employee gross sales (-1 to end): 4235
Employee Commission is $581.15
Enter employee gross sales (-1 to end): 600
Employee Commission is $254.00
Enter employee gross sales (-1 to end): 12500
Employee Commission is $1325.00
Enter employee gross sales (-1 to end): -1
Employees in the range:
$200-$299 : 1
$300-$399 : 0
$400-$499 : 0
$500-$599 : 1
$600-$699 : 0
$700-$799 : 0
$800-$899 : 0
$900-$999 : 0
Over $1000: 2

Computer Science & Information Technology

You might also like to view...

Which statement opens a file and links it to a file stream object?

A) open(AFile) = link(anObject); B) file.open("filename.txt"); C) linkstream("filename.txt"); D) link(open(filename.txt")); E) None of the above

Computer Science & Information Technology

What would be the effect of the following commands?

a. ls $let/.. b. cat $prop/sys.A >> $let/no.JSK c. echo $let/* d. cp $let/no.JSK $progs Suppose that your HOME directory is /users/steve. Assuming that you just logged in to the system and executed the following commands $ docs=/users/steve/documents $ let=$docs/letters $ prop=$docs/proposals

Computer Science & Information Technology

One goal of normalization is to minimize anomalies, in particular three anomalies—insert, delete, and update

Indicate whether the statement is true or false

Computer Science & Information Technology

The ARping command has the word _______________ in its output.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology