我正在做一个程序,该程序将输入该周的每周工资和总工作时间。它应该以小时工资率显示答案。但我无法显示正确的“centavos/2 个小数位”公式,并且它不想使用 float % float 运行。请帮忙!
#include <stdio.h>
int gethourpaypes(int weekpay, int hoursworked)
{
int hourpaypes;
hourpaypes = weekpay / hoursworked;
return hourpaypes;
}
int gethourpaycent(int weekpay, int hoursworked)
{
int hourpaycent;
hourpaycent = ((weekpay / hoursworked) % 100);
return hourpaycent;
}
int main()
{
int hourpaypes, weekpay, hoursworked;
int hourpaycent;
printf("Enter total week pay in pesos: ");
scanf("%d", &weekpay);
printf("Enter total hours worked that week: ");
scanf("%d", &hoursworked);
hourpaypes = gethourpaypes(weekpay, hoursworked);
hourpaycent = gethourpaycent(weekpay, hoursworked);
printf("Your hourly pay rate is %.0d pesos and %.2d centavos", hourpaypes, hourpaycent);
fflush(stdin);
getchar();
}