EXERCISE 3
Write a program to calculate a salary of a salesperson based on the unit of items sold.
Get the staff name, salary and the units sold.
Get the bonus percentage for sales as shown in the following table, based on the units sold.
o The bonus amount is the bonus percentage of the salary.
Calculate the total salary for the salesperson.
Display the name, salary, units sold, bonus percentage, bonus amount and total salary.
Design your own format of an appropriate output for this program.
Hello guys. I need help to solve this kind of question. I have done my own programming but it seems to have some errors. I have tried and searched all the possible solutions to solve this matter but the outcomes are still the same. I would appreciate if someone can help me to solve this kind of problem. Thanks in advance.
Below is the code that I have done. I hope you guys can fix it or give me a clue/hint on how to solve this question.
Code:#include <stdio.h> #include <string.h> void main() { int unit; float salary; char staff[20] , bonus; printf("\n-------------------------------------"); printf("\n BONUS "); printf("\n-------------------------------------"); printf("\nEnter the staff name : "); gets (staff); printf("\nEnter the salary : RM "); scanf("%f", &salary); printf("\nEnter the units sold : "); scanf("%d", &unit); salary = unit * bonus; if (unit > 100 || unit < 200){ strcpy(bonus, "0.02"); } else if (unit > 201 || unit < 300){ strcpy(bonus, "0.04"); } else if (unit > 300){ strcpy(bonus, "0.06"); } salary = unit * bonus; printf("\nStaff name : %s ", staff); printf("\nSalary : %f ", salary); printf("\nUnits Sold : %d ", unit); printf("\nBonus Percentage : %.2f ", bonus); printf("\nBonus Amount : "); printf("\nTotal Salary : RM"); return 0; }



LinkBack URL
About LinkBacks


