#include<iostream>
#include<limits>
#include<stdio.h>
using namespace std;
int main()
{
cout<<"*************************************************************"<<endl;
cout<<"Enter the number corresponding to the despayired rate or action:"<<endl;
cout<<"1) $8.7/hr 2)$9.33/hr "<<endl;
cout<<"$10.00/hr 3)$11.20/hr"<<endl;
cout<<"quit"<<endl;
int si,hi; double monper,money,taxes,hour;
cout<<"choose the number!"<<endl;
cout<<"*************************************************************"'
while(1)
{
cin>>si; // 输入一个数 ,例如124abc 那么 124 放入缓冲区。
if(getchar()=='\n') 从缓冲区读剩余的内容,例子中 读出“abc” 如果是 '/n' 代表 输入的数全部 符合 整形 。
{
switch(si)
{
case 1:monper=8.7;break;
case 2:monper=9.33;break;
case 3:monper=10.00; break;
case 4:monper=11.20;break;
case 5: return 0;
default : {cout<<"error! chose again!"<<endl;continue;}
}
cout<<"input the hour of work"<<endl;
}
else
{
continue;
}
cin>>hour;
while(cin.rdstate()||getchar(hour)!='\n')
{
{cout<<"error ,input the hour again!"<<endl;
cin.clear();
cin.ignore( numeric_limits<streamsize>::max(),'\n');
}
cin>>hour;
}
// calculate:
if(hour>40)
hour=(hour-40)*1.5+40;
money=hour*monper;
if(money>=300)
{
taxes=300*0.15;
if(money>=450)
{
taxes+=150*0.2;
taxes+=(money-450)*0.25;
}
else if(money<450)
taxes+=(money-300)*0.2;
}
else
taxes=money*0.15;
cin.clear();
cin.ignore( numeric_limits<streamsize>::max(),'\n');
cout<<money<<" "<<taxes<<" "<<money-taxes<<endl;
cout<<"choose the number"<<endl;
}
return 0;
}
#include<limits>
#include<stdio.h>
using namespace std;
int main()
{
cout<<"*************************************************************"<<endl;
cout<<"Enter the number corresponding to the despayired rate or action:"<<endl;
cout<<"1) $8.7/hr 2)$9.33/hr "<<endl;
cout<<"$10.00/hr 3)$11.20/hr"<<endl;
cout<<"quit"<<endl;
int si,hi; double monper,money,taxes,hour;
cout<<"choose the number!"<<endl;
cout<<"*************************************************************"'
while(1)
{
cin>>si; // 输入一个数 ,例如124abc 那么 124 放入缓冲区。
if(getchar()=='\n') 从缓冲区读剩余的内容,例子中 读出“abc” 如果是 '/n' 代表 输入的数全部 符合 整形 。
{
switch(si)
{
case 1:monper=8.7;break;
case 2:monper=9.33;break;
case 3:monper=10.00; break;
case 4:monper=11.20;break;
case 5: return 0;
default : {cout<<"error! chose again!"<<endl;continue;}
}
cout<<"input the hour of work"<<endl;
}
else
{
cout<<"error ,input again!"<<endl;
cin.clear();
cin.ignore( numeric_limits<streamsize>::max(),'\n');continue;
}
cin>>hour;
while(cin.rdstate()||getchar(hour)!='\n')
{
{cout<<"error ,input the hour again!"<<endl;
cin.clear();
cin.ignore( numeric_limits<streamsize>::max(),'\n');
}
cin>>hour;
}
// calculate:
if(hour>40)
hour=(hour-40)*1.5+40;
money=hour*monper;
if(money>=300)
{
taxes=300*0.15;
if(money>=450)
{
taxes+=150*0.2;
taxes+=(money-450)*0.25;
}
else if(money<450)
taxes+=(money-300)*0.2;
}
else
taxes=money*0.15;
cin.clear();
cin.ignore( numeric_limits<streamsize>::max(),'\n');
cout<<money<<" "<<taxes<<" "<<money-taxes<<endl;
cout<<"choose the number"<<endl;
}
return 0;
}