帮我写一个c程序:某公司员工的工资计算方法如下:一周内工作时间不超过40小时,按正常工作时间计酬;超出40小时的工作时间部分,按正常工作时间报酬的1.5倍计酬。员工按进公司时间分为新职工和老职工,进公司不少于5年的员工为老职工,5年以下的为新职工。新职工的正常工资为30元/小时,老职工的正常工资为50元/小时。请按该计酬方式计算员工的工资。
时间: 2023-03-24 14:04:57 浏览: 169
以下是C语言程序代码:
#include <stdio.h>
int main() {
int hours, years;
float salary, normal_salary, overtime_salary;
printf("请输入员工工作的小时数:");
scanf("%d", &hours);
printf("请输入员工在公司工作的年数:");
scanf("%d", &years);
if (years >= 5) {
normal_salary = 50;
} else {
normal_salary = 30;
}
if (hours <= 40) {
salary = hours * normal_salary;
} else {
overtime_salary = normal_salary * 1.5;
salary = 40 * normal_salary + (hours - 40) * overtime_salary;
}
printf("员工的工资为:%.2f元\n", salary);
return ;
}
阅读全文