一家笔记本电脑制造公司对其销售人员的月度薪酬政策如下 -
最低基本工资:3000.00
奖金每售出一台电脑:200.00
每月总销售额的佣金:5%
由于笔记本电脑的价格不断变化,每台笔记本电脑的销售价格在月初是固定的每个月。
查找奖金和佣金的逻辑如下 -
bonus = BONUS_RATE * quantity ; commission = COMMISSION * quantity * price ;
总工资是使用下面给出的公式计算的 -
Gross salary = basic salary + (quantity * bonus rate) + (quantity * Price) * commission rate
以下是使用宏函数计算销售人员工资的 C 程序 -
现场演示
#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) ; }
执行上述程序时,会产生以下输出 -
Number of items sold and their price 20 150000 Bonus = 4000.00 Commission = 150000.00 Gross salary = 157000.00
以上是C程序用宏函数计算销售员的工资的详细内容。更多信息请关注PHP中文网其他相关文章!