第1个回答 2012-08-19
#include<iostream>
using namespace std;
int main()
{
double weekprice,dol,cent,time;
cout<<"请输入一周薪水"<<endl;
cin>>weekprice;
fflush(stdin);
cout<<"请输入工作时间"<<endl;
cin>>time;
if(weekprice/time==0)
{
cent=(int)(weekprice*10.0/time);
cout<<"Your average hourly pay rate is 0 dollars and"<<cent<<" cents."<<endl;
return 0;
}
else
{
dol=(int)(weekprice/time);
cent=(int)((weekprice-dol*time)*10.0/time);
cout<<"Your average hourly pay rate is "<<dol<<" dollars and "<<cent<<" cents."<<endl;
return 0;
}
}本回答被网友采纳
第2个回答 2012-08-20
#include<iostream>
using namespace std;
int main()
{
double weekSalary,workingTime;
int dol,cent;
do
{
cout<<"请输入一周薪水,输入须为数值且不小于零,单位为“美元”)"<<endl;
cin>>weekSalary;
}while(weekSalary<0)
do
{
cout<<"请输入工作时间,输入须为数值且大于0.0小于168.0,单位为“小时”)"<<endl;
cin>>workingTime;
}while(workingTime<=0)
if(weekprice/workingTime==0)
{
cent=(int)(weekSalary*10.0/workingTime);
cout<<"Your average hourly pay rate is 0 dollars and"<<cent<<" cents."<<endl;
}
else
{
dol=(int)(weekSalary/workingTime);
cent=(int)((weekSalary-dol*workingTime)*10.0/wokingTime);
cout<<"Your average hourly pay rate is "<<dol<<" dollars and "<<cent<<" cents."<<endl;
}
return 0;
}
第3个回答 推荐于2018-04-27
#include<stdio.h>
main()
{
float dollar;
float hour;
float a;
float b;
float c;
printf("your salary is:");
scanf("%f,&dollar);
printf("working hour:");
scanf("%f,&hour);
a=dollar/hour;
b=a-(int)a;
c=a-b;
printf("your average hourly pay rate is %.0f dollars and %.0f cents",c,100*b);
return 0;
}本回答被网友采纳