In: Computer Science
A company pays its five salespeople on a commission basis. The salespeople receive $200 plus 10% of their sale. For example, for the employee sale of $1000, the commission is $300.
Write a C program that:
Program Code Screenshot
Program Sample Input/Output Screenshot
Program Code to Copy
#include <stdlib.h>
#include <stdio.h>
int main(void)
{
// a one-dimensional array for the sales people commissions
float commissions[1000];
int k = 0;
// use sentinel loop
while (1)
{
printf("Enter Sales value (-1 to stop): ");
float val;
scanf("%f", &val);
if (val == -1)
{
break;
}
// calculates each employee commission
commissions[k++] = 200 + (val * 0.1);
}
// prints out each employee commission
printf("Each Employee Commission...\n");
for (int i = 0; i < k; i++)
{
printf("Employee %d: $%0.2f\n", i + 1, commissions[i]);
}
// calculate the total sum of all commissions paid, and print
float total_sum = 0;
for (int i = 0; i < k; i++)
{
total_sum += commissions[i];
}
printf("Total Commissions Paid = $%0.2f", total_sum);
}