Answer to Question #239930 in C for ben

Question #239930

Sales Commissions) 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% 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. 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

268 Chapter 6 C Arrays

e) $600–699

f) $700–799

g) $800–899

h) $900–999

i) $1000 and over


1
Expert's answer
2021-09-21T06:47:33-0400
// Chapter 6 Exercise
// 6.10 Sales Commissions

#include <stdio.h>

// Function main begins program execution
int main(void) {
    unsigned int grossSales;
    unsigned int employeeCounter = 1;
    size_t category; // counter for array of commission
    int commissions[9] = {0}; // initialize the frequency of all category to zero

    printf("Enter MR (%2u) 's gross sales (-1 to stop): ", employeeCounter);
    scanf("%u", &grossSales);
    employeeCounter++;
    while (grossSales != -1) {
        if (0.09 * grossSales >= 200) {
            if (0.09 * grossSales >= 300) {
                if (0.09 * grossSales >= 400) {
                    if (0.09 * grossSales >= 500) {
                        if (0.09 * grossSales >= 600) {
                            if (0.09 * grossSales >= 700) {
                                if (0.09 * grossSales >= 800) {
                                    if (0.09 * grossSales >= 900) {
                                        if (0.09 * grossSales >= 1000) {
                                            commissions[8]++;
                                        } else {
                                            commissions[7]++;
                                        }
                                    } else {
                                        commissions[6]++;
                                    }
                                } else {
                                    commissions[5]++;
                                }
                            } else {
                                commissions[4]++;
                            }
                        } else {
                            commissions[3]++;
                        }
                    } else {
                        commissions[2]++;
                    }
                } else {
                    commissions[1]++;
                }
            } else {
                commissions[0]++;
            }
        }
        printf("Enter MR (%2u) 's gross sales (-1 to stop): ", employeeCounter);
        scanf("%u", &grossSales);
        employeeCounter++;
    }

    printf("%s", "Commissions Frequency\n");

    printf("$ 200 - 299 %2d\n", commissions[0]);
    printf("$ 300 - 399 %2d\n", commissions[1]);
    printf("$ 400 - 499 %2d\n", commissions[2]);
    printf("$ 500 - 599 %2d\n", commissions[3]);
    printf("$ 600 - 699 %2d\n", commissions[4]);
    printf("$ 700 - 799 %2d\n", commissions[5]);
    printf("$ 800 - 899 %2d\n", commissions[6]);
    printf("$ 900 - 999 %2d\n", commissions[7]);
    printf("$ 1000 and above %2d\n", commissions[8]);

    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS