請問if-elseif-else:計算工讀薪資的程式怎寫? - 工讀

Table of Contents

if-elseif-else:計算工讀薪資作業內容:假設某加油站的工讀生每個月打工的薪資,可以依照下列方式計算:60個小時之內,基本時新為每小時100元61~75個小時,以基本時新的1.5倍計算76個小時以後,以基本時新的2倍計算請寫一程式可讓使用者輸入工讀時數(使用prompt),並計算其薪資....Showmore

All Comments

Zora avatarZora2007-05-03
我想題意應該是這樣,所以把上面網友的回答改了一些些#includeusingnamespacestd;intmain(){floathour;do//用於重複輸入{cin>>hour;if(hour<=60)cout<<hour*100<<endl;elseif(hour>=61&&hour<=75)cout<<(hour-60)*100*1.5+6000<<endl;//超過60小時的部分,再加基本60小時elsecout<<(hour-75)*100*2+2250+6000<<endl;//�
Sarah avatarSarah2007-05-04
#includeintmain(){floathour,rate;do{cout<<"請輸入工作時數(輸入0則結束):";cin>>hour;if(hour==0)break;//輸入工時為0時,結束迴圈rate=((hour<=60)?1:((hour<=75)?1.5:2));cout<<"工時:"<
Christine avatarChristine2007-05-04
#includeusingnamespacestd;intmain(){floathour;while(cin>>hour)//用於重複輸入{if(hour<=60)cout<<hour*100<<endl;elseif(hour>=61&&hour<=75)cout<<hour*100*1.5<<endl;elsecout<<hour*100*2<<endl;}return0;}...Showmore