-
help w/ array problem
i'm having a problem with a homework question and i was hoping someone could give me a little help. Here it is:
6.10 Use a single-subscripted array to solve the following problem. A company pays its salespeople on a commission basis. The salespeople recieve $200 per week plus 9 percent of their gross sales for that week. For example, a salesperson who grosses $3000 in sales in a week recieves $200 plus 9 percent of $3000, or a total of $470. Write a C 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 and over
(end of problem)
Now either this problem is so simple and i'm not reading it right or i just don't have a clue! Any help would be great!
-
well, try rereading the problem...but: check through the salaries using if statements to check values and add to the counters...for example
array[0]++;
hope this helps...
-
problem w/array question
<<mod snipped reposted question - answers merged into one thread>>
-
I'm not going to write the program for you, but I'll help you out a bit. The exercise assumes that certain data is already present, such as data read from a datafile. Data that is unknown includes the number of total employees and each employee's weekly sales.
Unless your instructor says otherwise, there are many different methods of creating samples to test out your program, such as a datafile or keyboard input. The easiest method in your case is to have a create a seperate array (initialized to the total amount of employees), and using a for loop with a scanf("%d", &array[i]) to read in each employee's weekly sales.
Finding the the number of employees in each category requires a second array and some algebra.