Hi, i have been trying to do the following problem for homework, ialthough i have been able to input some code using the psuedocode given to me im am completely stuck now, and i was wondering if anyone could show me what i am missing?

Question

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 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 following ranges (assume that each salesperson’s salary is truncated to an integer amount):


1. $200-$299
2. $300-$399
3. $400-$499
4. $500-$599
5. $600-$699
6. $700-$799
7. $800-$899
8. $900-$999
9. $1000-over

1.	#include <iostream>
2.	 
3.	using std::cout;
4.	using std::cin;
5.	using std::endl;
6.	using std::ios;
7.	 
8.	#include <iomanip>
9.	 
10.	using std::setw;
11.	using std::setiosflags;
12.	using std::setprecision;
13.	 
14.	void wages( int [] );  
15.	void display( const int [] );    
16.	 
17.	int main()    
18.	{
19.	    variable declarations
20.	    int salaries [ 11 ] = { 0 };    
21.	    
22.	    wages( salaries );
23.	    display( salaries );
24.	 
25.	return 0;
26.	 
27.	} 
28.	 
29.	 
30.	void wages ( int money[] )    
31.	{
32.	    
33.	    double     sales,                 
34.	        commissionRate = 0.09
35.	        salary,              
36.	 
37.	 
38.	 
39.	 
40.	    
41.	do
42.	{
43.	        cout << "Enter employee gross sales ( -1 to end )" << endl;
44.	        cin >> sales;
45.	} while(sales >= 0);
46.	 
47.	    } 
48.	}

There are 9 salary ranges but i dont know how to input an array of 9 elements to hold these ranges (which is hwta i think i should be doing)

I think that the function to calculate the salary should return a number corresponding to the array element that needs to be incremented. The function argument would be the salary. But i have no idea how I would do this?

41.	do
42.	{
43.	        cout << "Enter employee gross sales ( -1 to end )" << endl;
44.	        cin >> sales;
45.	} while(sales >= 0);
46.

you don't need variable sales. You can enter the values directly into the money array by using a loop counter, comething like below. Note you also have to test the value of the loop counter to make sure it doesn't go beyone the bounds of the array.

int i = 0;
do
{
    cout << "Enter employee gross sales ( -1 to end )" << endl;
    cin >> money[i];
    
} while( i < 10 &&  money[i] >= 0);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.