• Language

    C

  • Description

    A large 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 sells $5,000 worth of merchandise in a week receives $200 plus 9% of $5,000, or a total of $650. You have been supplied with a list of the items sold by each salesperson. The values of these items are as follows:
    Item | Value
    1 | 239.99
    2 | 129.75
    3 | 99.95
    4 | 350.89
    Develop an application that inputs the items sold of one salesperson for the last week, then calculates and displays that earnings of the salesperson. There is no limit to the number of items that can be sold by a salesperson.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <stdio.h>
#include <stdlib.h>

int main (void)
{
    float commission, earnings, gross_sales_in_the_week, sold_1_items, sold_2_items;
    float sold_3_items, sold_4_items, weekly_salary;
    printf ("Enter the value of sold 1 items: ");
    scanf ("%f", &sold_1_items);
    (void) getchar ();
    printf ("Enter the value of sold 2 items: ");
    scanf ("%f", &sold_2_items);
    (void) getchar ();
    printf ("Enter the value of sold 3 items: ");
    scanf ("%f", &sold_3_items);
    (void) getchar ();
    printf ("Enter the value of sold 4 items: ");
    scanf ("%f", &sold_4_items);
    (void) getchar ();
    weekly_salary=200;
    gross_sales_in_the_week=sold_1_items*239.99+sold_2_items*129.75+sold_3_items*99.95+sold_4_items*350.89;
    commission=gross_sales_in_the_week*0.09;
    earnings=weekly_salary+commission;
    printf ("Value of commission: %g\n", commission);
    printf ("Value of earnings: %g\n", earnings);
    printf ("Value of gross sales in the week: %g\n", gross_sales_in_the_week);
    printf ("Value of weekly salary: %g\n", weekly_salary);
    putchar ('\n');
    system ("pause");
    return EXIT_SUCCESS;
}