Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Use a single subscripted array to solve the following problem. Acompany pays its

ID: 3608899 • Letter: U

Question

Use a single subscripted array to solve the following problem. Acompany pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9 percent of their gross salesfor that week. For example, a sales person who grosses $3000 insales in a week receives $200 plus 9% of $3000, or a total of $470.Write a C program using an array of counters that determines howmany of the salespeople earned salaries in each of the followingranges (assume that each salesperson's salary is truncated to aninteger 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.

Explanation / Answer

#include<stdio.h>
#include <conio.h>
int main()
{int i,j,counter[9]={0};
float sales;
printf("Enter sales (negative to exit): ");
scanf("%f",&sales);
while(sales>=0)
   {sales=200+.09*sales;
    printf("Salary= %.2f ",sales);
    i=(sales-200)/100;
    if(i>8)
        i=8;
    counter[i]++;
    printf("Enter sales (negative to exit): ");
    scanf("%f",&sales);
   }
printf("The final sales tally is sales count ");

for(i=0;i<7;i++)
   {j=i*100+200;
   printf("$%d-%d %d ",j,j+99,counter[i]);
   }
printf("$1000 and over %d ",counter[8]);
getch();
}
   
/*   sample run
Enter sales (negative to exit): 2000
Salary= 380.00
Enter sales (negative to exit): 2000.66
Salary= 380.06
Enter sales (negative to exit): 10000
Salary= 1100.00
Enter sales (negative to exit): 15000.44
Salary= 1550.04
Enter sales (negative to exit): 12000
Salary= 1280.00
Enter sales (negative to exit): 99.99
Salary= 209.00
Enter sales (negative to exit): 50.99
Salary= 204.59
Enter sales (negative to exit): 0
Salary= 200.00
Enter sales (negative to exit): -1
The final sales tally is
sales        count
$200-299         3
$300-399         2
$400-499         0
$500-599         0
$600-699         0
$700-799         0
$800-899         0
$1000 and over    3
*/