- 分享
- 0
- 人气
- 0
- 主题
- 5
- 帖子
- 4516
- UID
- 140257
- 积分
- 10923
- 阅读权限
- 25
- 注册时间
- 2008-5-2
- 最后登录
- 2021-2-3
- 在线时间
- 3371 小时
|
回复 #28 Super-Tomato 的帖子
大概明白你的意思了
- #include<iostream>
- using namespace std;
- int main()
- {
- int number,pay,n,j,k,l;
- char choice;
- while(1)
- {
- cout<<"Enter the paycode\n 1 for manager\n 2 for hourly worker\n 3 for commission worker\n 4 for piece worker\n";
- cin>>number;
- switch(number)
- {
- case 1:
- cout<<"Please enter the weekly salary\n";
- cin>>n;
- cout<<"The weekly salary for manager is "<<n<<"\n";
- break;
- case 2:
- cout<<"Please key in the payrate";
- cin>>n;
- cout<<"Please key in hoursworked\n";
- cin>>j;
- cout<<"Please key in the hourlypay for exceed 40 hoursworked, else input 0 \n";
- cin>>k;
- cout<<"Please key in the OT hoursworked, only applicable if hoursworked exceed 40 hours, else input 0\n";
- cin>>l;
- if(j>40)
- {
- pay=n*j+(1.5*k*l);
- }
- if(j<=40)
- {
- pay=n*j;
- }
- cout<<"The weekly pay for houly worker is "<<pay<<"\n";
- break;
- case 3:
- cout<<"Please key in weeklysales\n";
- cin>>n;
- pay=250+(n*0.057);
- cout<<"The weekly pay for commission worker is "<<pay<<"\n";
- break;
- case 4:
- cout<<"Please key in item produced\n";
- cin>>n;
- cout<<"Please key in item price\n";
- cin>>j;
- pay=n*j;
- cout<<"The weekly pay for piece worker is "<<pay<<"\n";
- break;
- default:
- cout<<"Wrong number\n";
- break;
- }
- label: cout<<"Do you wish to continue(Y/N)?\n";
- cin>>choice;
- if(choice=='Y') continue;
- else if(choice=='N') break;
- else
- {
- cout<<"Wrong choice..Type again\n";
- goto label;
- }
- }
- return 0;
- }
复制代码 |
|