A salesperson gets a yearly bonus based on a commission from collections of sales and review from peers. Sales will be calculated for 12 months and the commission is rated based on an average sales table (shown in the next page). Other salesperson in the company will give points for peer review. The average from the peer review determines the review rate. Write a complete C program based on the above situation and the following instructions. Declare a structure of Sales Executive record called SalesExecutive that has: ∙ Sales Executive name : exec_name (string) ∙ Basic salary : basic_salary (float) ∙ Average sales : averageSales (float) ∙ Average peer review : averagePeerReview (float) ∙ Total yearly bonus : yearlyBonus (float) In function main() : ∙ Create a structure variable named staff ∙ Prompt user to enter sales executive name (exec_name) and his/her basic salary (basic_salary). ∙ Call function calc_averageSales () to key-in and calculate the average sales obtained in 12 months. Return the average and store the average sales in averageSales. ∙ Call function getCommissionRate (…) and pass averageSales as the parameter to determine the commission rate. Return the rate. ∙ Next, prompt user to enter number of sales executive in the company. ∙ Call function calc_AveragePeerReview (…) and pass the number of the sales executives as entered earlier. Return the average and store it in averagePeerReview. ∙ Call function getReviewRate(…) and pass averagePeerReview as the parameter to determine the review rate. Return the rate. ∙ Next, calculate the amount of bonus based on commission rate. ∙ Bonus from commission = commission rate X average of sales ∙ Then, calculate the amount of bonus from peer review. ∙ Bonus from peer review = review rate X basic salary ∙ Then, calculate the total bonus of the year by adding the two bonus amounts. ∙ Display all the details of the Sales Executive record as shown in the sample output. LECTURE EXERCISE – CHAPTER 7 SNK/2020 LECTURE EXERCISE – CHAPTER 7 iii. In function calc_averageSales (): ∙ Declare a prototype for this function. ∙ Create an array to store the collection of sales for 12 months. ∙ Using for loop, prompt the user to enter the collection of sales ∙ Store the input in the array accordingly. ∙ Calculate total of the sales. ∙ Then, calculate the average of the sales. ∙ Return the average sales. In function getCommissionRate(…): ∙ Declare a prototype for this function. ∙ Using if-else statements, determine the rate based on the average sales. Refer to the following table: Average Sales (RM) Commission Rate (%) Less than 8000 0 8000 - 15000 10 15999 - 20000 15 More than 20000 20 ∙ Return the commission rate. In function calc_AveragePeerReview(…): ∙ Declare a prototype for this function. ∙ Create an array to store the peer reviews based on the number of salespersons. ∙ Using for loop, prompt the user to enter rating from each peer. ∙ Store the input in the array accordingly. ∙ Calculate total rating of the review. ∙ Then, calculate the average of the peer review rating ∙ Return the average peer rating In function getReviewRate(…): ∙ Declare a prototype for this function. ∙ Using if-else statements, determine the rate based on the average rating from peers. Refer to the following table: Average rating Review Rate (%) Less than 2.50 0 Less than 3.00 2 Less than 4.00 3.5 4.00 – 5.00 7 ∙ Return the review rate.
A salesperson gets a yearly bonus based on a commission from collections of sales and review from peers. Sales will be calculated for 12 months and the commission is rated based on an average sales table (shown in the next page). Other salesperson in the company will give points for peer review. The average from the peer review determines the review rate.
Write a complete C program based on the above situation and the following instructions.
- Declare a structure of Sales Executive record called SalesExecutive that has: ∙ Sales Executive name : exec_name (string)
∙ Basic salary : basic_salary (float)
∙ Average sales : averageSales (float)
∙ Average peer review : averagePeerReview (float)
∙ Total yearly bonus : yearlyBonus (float)
- In function main() :
∙ Create a structure variable named staff
∙ Prompt user to enter sales executive name (exec_name) and his/her basic salary (basic_salary).
∙ Call function calc_averageSales () to key-in and calculate the average sales obtained in 12 months. Return the average and store the average sales in averageSales.
∙ Call function getCommissionRate (…) and pass averageSales as the parameter to determine the commission rate. Return the rate.
∙ Next, prompt user to enter number of sales executive in the company.
∙ Call function calc_AveragePeerReview (…) and pass the number of the sales executives as entered earlier. Return the average and store it in averagePeerReview.
∙ Call function getReviewRate(…) and pass averagePeerReview as the parameter to determine the review rate. Return the rate.
∙ Next, calculate the amount of bonus based on commission rate.
∙ Bonus from commission = commission rate X average of sales
∙ Then, calculate the amount of bonus from peer review.
∙ Bonus from peer review = review rate X basic salary
∙ Then, calculate the total bonus of the year by adding the two bonus amounts. ∙ Display all the details of the Sales Executive record as shown in the sample output.
LECTURE EXERCISE – CHAPTER 7 SNK/2020 |
LECTURE EXERCISE – CHAPTER 7
iii. In function calc_averageSales ():
∙ Declare a prototype for this function.
∙ Create an array to store the collection of sales for 12 months.
∙ Using for loop, prompt the user to enter the collection of sales
∙ Store the input in the array accordingly.
∙ Calculate total of the sales.
∙ Then, calculate the average of the sales.
∙ Return the average sales.
- In function getCommissionRate(…):
∙ Declare a prototype for this function.
∙ Using if-else statements, determine the rate based on the average sales. Refer to the following table:
Average Sales (RM) |
Commission Rate (%) |
Less than 8000 |
0 |
8000 - 15000 |
10 |
15999 - 20000 |
15 |
More than 20000 |
20 |
∙ Return the commission rate.
- In function calc_AveragePeerReview(…):
∙ Declare a prototype for this function.
∙ Create an array to store the peer reviews based on the number of salespersons. ∙ Using for loop, prompt the user to enter rating from each peer.
∙ Store the input in the array accordingly.
∙ Calculate total rating of the review.
∙ Then, calculate the average of the peer review rating
∙ Return the average peer rating
- In function getReviewRate(…):
∙ Declare a prototype for this function.
∙ Using if-else statements, determine the rate based on the average rating from peers. Refer to the following table:
Average rating |
Review Rate (%) |
Less than 2.50 |
0 |
Less than 3.00 |
2 |
Less than 4.00 |
3.5 |
4.00 – 5.00 |
7 |
∙ Return the review rate.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 6 images