i have this project to do for class. i get how the program works.here is the project:
Use a single subscript array and functions to solve the following problem. A company pays its salespeople on a commission basis. The salesperson receives $200 per week plus 9 percent of his/her gross sales for that week. For example; a salesperson whose gross sale is $3000 in a week receives $200 plus 9% of $3000, or a total of $470. Write a C program using arrays and function) that determines how many of the sales people earned salaries in the following ranges (assume that each salesperson’s salary is truncated to an integer amount):
- $200-$299
- $300-$399
- $400-$499
- $500-$599
- $600-$699
- $700-$799
- $800-$899
- $900-$999
- $1000-over
You can assume that the company has a sale force of 50 employees.
You out should include a histogram
I wrote this program but i stuck. i'm confused a whole lot. can anyone help me PLEASE.
thanks
#include <stdio.h>
#define SIZE 10
void chart (int p[], int r[]);
int main()
{
int range[SIZE]={0};
int sales[20]=
{ 267, 359, 468, 525, 678, 710, 856, 867, 920, 1067,
254, 987, 1034, 875, 345, 765, 234, 500, 300, 490};
int p[20];
for( int i=0; i<14; i++)
{
p[i]= (200+.09*sales[i]);
}
printf("%7d%13d ", i,sales[i]);
chart(p[], r[])
return 0;
}
void chart ( int p[], int r[])
{
for( int i= 0; i<14; i++)
{
if ( p[i] >0 && p[i] <200){
++ r[0];
}
else if (p[i] >=200 && p[i] <300){
++ r[1];
}
else if (p[i] >=300 && p[i] <400){
++ r[2];
}
else if (p[i] >=400 && p[i] <500){
++ r[3];
}
else if (p[i] >=500 && p[i] <600){
++ r[4];
}
else if (p[i] >=600 && p[i] <700){
++ r[5];
}
else if (p[i] >=700 && p[i] <800){
++ r[6];
}
else if (p[i] >=800 && p[i] <900){
++ r[7];
}
else if (p[i] >=900 && p[i] <1000){
++ r[8];
}
else if (p [i] >1000){
++ r[9];
}
}
}
for( int i=0; i<=size; i++)
{
printf("%7d%13d ",i, r[i]);
}