关于C++中cin的问题

来源:百度知道 编辑:UC知道 时间:2024/07/06 21:10:05
#include<iostream.h>
int main()
{
int hour;
float w;
double wage;
cout<<"Please input employee's work time and wage_per_hour:"<<endl;
cin>>hour;
cin>>w;

while(hour)
{
if(hour<=40)
wage=hour*w;
else if(hour<=50)
wage=40*w+(hour-40)*w*1.5;
else
wage=40*w+10*w*1.5+(hour-50)*w*3;
}
cout<<"The employee's wage: "<<wage<<endl;
return 0;
}

while(hour)
{
if(hour<=40)
wage=hour*w;
else if(hour<=50)
wage=40*w+(hour-40)*w*1.5;
else
wage=40*w+10*w*1.5+(hour-50)*w*3;
cin>>hour;//如果你想循环输入的话,那么这地方还要加一个 cin;
}

#include<iostream.h>
int main()
{
int hour;
float w;
double wage;
while(hour)
{
cout<<"Please input employee's work time and wage_per_hour:"<<endl;
cin>>hour;
cin>>w;
if(hour<=40)
wage=hour*w;
else if(hour<=50)
wage=40*w+(hour-40)*w*1.5;
else
wage=40*w+10*w*1.5+(hour-50)*w*3;
cout<<"The employee's wage: "<<wage<<endl;
}
return 0;
}

你是想要这个结果吗?
你运行以下试一试

#include<iostream.h>
int main()
{
int hour;
float w;
double wage;
cout<<"Please input employee's work