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

6.10 (Sales Commissions) Use a one-dimensional array to solve the following prob

ID: 3759422 • Letter: 6

Question

6.10 (Sales Commissions) Use a one-dimensional array to solve the following problem.

A company pays its salespeople on a commission basis. The salespeople receive $200 per week
plus 9% of their gross sales for that week. For example, a salesperson who grosses $3,000
in sales in a week receives $200 plus 9% of $3,000, or a total of $470.

Assuming a company has 20 salespeople, 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):

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>

void main()
{
   int person[9],i,co,s,ns;

   for(i=0;i<9;i++)
   {
       person[i]=0;
   }
   for(i=0;i<20;i++)
   {
       printf("Enter sale");
       scanf("%d",&ns);
       co=ns*9/100;
       s=co+200;
      
       if(s>=200 && s<=299)
       {
           person[0]=person[0]+1;
       }
      
       if(s>=300 && s<=399)
       {
           person[1]=person[1]+1;
       }      

       if(s>=400 && s<=499)
       {
           person[2]=person[2]+1;
       }

       if(s>=500 && s<=599)
       {
           person[3]=person[3]+1;
       }

       if(s>=600 && s<=699)
       {
           person[4]=person[4]+1;
       }

       if(s>=700 && s<=799)
       {
           person[5]=person[5]+1;
       }

       if(s>=800 && s<=899)
       {
           person[6]=person[6]+1;
       }

       if(s>=900 && s<=999)
       {
           person[7]=person[7]+1;
       }
       if(s>=1000)
       {
           person[8]=person[8]+1;  
       }
   }

   for(i=0;i<=8;i++)
   {
       printf(" count of Salaries= %d",person[i]);
   }
   getch();
}