#include <stdio.h>
int main()
{
int hours; //工作時(shí)數(shù)
float hourlyRate; //每小時(shí)工資
float salary; //應(yīng)得工資
printf("Enter # of hours worked (-1 to end): ");
scanf("%d", &hours);
while(hours !=-1){
printf("Enter hourly rate of the worker ($00.00): ");
scanf("%f",&hourlyRate);
//超過(guò)40小時(shí)以正常工資的1.5倍計(jì)算
if(hours>40){
salary=(float)hours*hourlyRate*1.5;
}
else{
salary=(float)hours*hourlyRate;
}
printf("Salary is $%.2f\n\n",salary);
printf("Enter # of hours worked (-1 to end):");
scanf("%d", &hours);
}
system("pause");
return 0;
}