#include <stdio.h>
int main()
{
int hours; //工作時數
float hourlyRate; //每小時工資
float salary; //應得工資
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);
//超過40小時以正常工資的1.5倍計算
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;
}