Create a C# application that will accept sales information and calculate the tot
ID: 641216 • Letter: C
Question
Create a C# application that will accept sales information and calculate the total commission for a sales associate.
There are 5 products which can be sold:
Product 1 with price of $6.98
Product 2 with price of $7.50
Product 3 with price of $3.75
Product 4 with price of $2.59
Product 5 with price of $23.79
The application should use a sentinel controlled loop to prompt the user for each product and quantity for a sales rep (one rep at a time),
Use a switch statement to identify the correct item price
Calculate the total sales for all items for that sales rep.
Be sure to use a sentinel controlled loop to determine the value of products sold for that sales rep.
Assume sales reps receive 10% commission on their total sales to calculate the sales rep commission.
Test with sets of data for 3 sales reps. Output the sales rep commission for each of the 3 sales reps.
Explanation / Answer
Simple C application that will accept sales information and calculate the total commission for a sales associate:
#include <stdio.h>
int main(void){
int type=0;
int quantity;
double total=0;
printf("Enter pairs of item numbers and quantities. ");
printf("Enter -1 for the item number to end input. ");
while(type!=-1){
scanf("%d %d",&type,&quantity);
switch(type){
case 1:
total=total+quantity*6.98;
break;
case 2:
total=total+quantity*7.50;
break;
case 3:
total=total+quantity*3.75;
break;
case 4:
total=total+quantity*2.59;
break;
case 5:
total=total+quantity*23.79;
break;
default:
printf("type is wrong:try again ");
break;
}
}
printf("Sum of the purchases is :%lf",total);
}