The monthly compensation policy of a laptop manufacturing company for its sales staff is as follows -
Minimum basic salary: 3000.00
Bonus per computer sold: 200.00
Commission on total monthly sales: 5%
Since the price of laptops is constantly changing, the sales price of each laptop The beginning of the month is fixed every month.
The logic to find bonus and commission is as follows-
bonus = BONUS_RATE * quantity ; commission = COMMISSION * quantity * price ;
The total salary is calculated using the formula given below-
Gross salary = basic salary + (quantity * bonus rate) + (quantity * Price) * commission rate
The following is a C program that uses macro functions to calculate sales staff wages-
Live demonstration
#define BASIC_SALARY 3000.00 #define BONUS_RATE 200.00 #define COMMISSION 0.05 main(){ int quantity ; float gross_salary, price ; float bonus, commission ; printf("number of items sold and their price</p><p>") ; scanf("%d %f", &quantity, &price) ; bonus = BONUS_RATE * quantity ; commission = COMMISSION * quantity * price ; gross_salary = BASIC_SALARY + bonus + commission ; printf("</p><p>"); printf("Bonus = %6.2f</p><p>", bonus) ; printf("Commission = %6.2f</p><p>", commission) ; printf("Gross salary = %6.2f</p><p>", gross_salary) ; }
When the above program is executed, the following output will be produced-
Number of items sold and their price 20 150000 Bonus = 4000.00 Commission = 150000.00 Gross salary = 157000.00
The above is the detailed content of C program uses macro function to calculate salesperson's salary. For more information, please follow other related articles on the PHP Chinese website!