


版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、1. 一、需求分析從要求上來看是要對各個員工的各種情況(名字、年齡、性別、職位、工資狀況)進行輸入。然后可以輸出.2. 可以對于員工數(shù)據(jù)進行修改,可以查詢.3. 對于員工的各種情況系統(tǒng)還可以進行統(tǒng)計排名.二、概要設(shè)計首先,創(chuàng)建了一個employee類.然后派生出四個類:manager、technician、salesman、salesmanager.在派生類中定義了三個構(gòu)造函數(shù)分別是:數(shù)據(jù)輸入函數(shù)(Input),表格輸出函數(shù)(Print),排序函數(shù)(Pay).其次,在總體結(jié)構(gòu)上,建立以各根菜單,用于選擇各種功能.1. Input(數(shù)據(jù)輸入):輸入員工的各種數(shù)據(jù).2. Total(數(shù)據(jù)統(tǒng)計):將
2、員工的總數(shù)據(jù)進行對比排序,然后輸出.3. Output(數(shù)據(jù)顯示):顯示輸入的各種數(shù)據(jù).4. Save(數(shù)據(jù)保存):對輸入的數(shù)據(jù)進行保存?zhèn)浞?5. Eixt(退出程序):執(zhí)行退出程序命令.1. 三、詳細設(shè)計Input(數(shù)據(jù)輸入):定義了各個崗位的人員的類,并把每個類的人員的屆性設(shè)為類中的保護成員,其中技術(shù)工的工作時間和每小時的所得為私有成員,而銷售員的銷售額、經(jīng)理的工資和銷售經(jīng)理的所轄部門的銷售額和其底薪設(shè)為公有成員,再依次錄入。2. Total(數(shù)據(jù)統(tǒng)計):根據(jù)所有類的工資算法在其所屆類中定義一個函數(shù)voidpay()來根據(jù)各個職位的具體情況來計算工資,并且算出的工資經(jīng)過冒泡法排序.void
3、printtotal()(cout<<""<<endl;cout<<"Total"<<setw(10)<<total<<""<<endl;cout<<""<<endl;Output(數(shù)據(jù)顯示):通過do-while循環(huán)以及制表格和setw的使用將輸入的數(shù)據(jù)和統(tǒng)計并排序的數(shù)據(jù)以表格的形式打印出來,銷售額合計一欄寬度要大些。voidsaleprint()(cout<<"|"<
4、<setw(10)<<no1<<"|"<<setw(10)<<name1<<"I"<<setw(10)<<sale1<<"|"<<endl;cout<<"|111"<<endl;cout<<"|"<<setw(10)<<no2<<"|"<<setw(10)<<name2
5、<<"I"<<setw(10)<<sale2<<"|"<<endl;cout<<"|111"<<endl;cout<<"|"<<setw(10)<<no3<<"|"<<setw(10)<<name3<<"I"<<setw(10)<<sale3<<"|"&l
6、t;<endl;cout<<"|111"<<endl;3. cout<<"|"<<setw(10)<<no4<<"|"<<setw(10)<<name4<<"I"<<setw(10)<<sale4<<"|"<<endl;voidprint()(cout<<"|11111"<<endl;cout
7、<<"|"<<setw(10)<<no<<"|"<<setw(10)<<name<<"I"<<setw(10)<<sex<<"|"<<setw(10)<<age<<"|"<<setw(10)<<salary<<"|"<<endl;Save(數(shù)據(jù)保存):通過函數(shù)save()來將
8、輸入的數(shù)據(jù)和統(tǒng)計并排序的數(shù)據(jù)進行保存.例如:voidsave()fstreamoutfile;outfile.open("f:flsdfj.txt",ios:app);if(!outfile)cout<<"fcan'topen.n"abort();outfile<<"Salesmanger"<<endl;outfile<<"ID"<<no<<"NAME"<<name<<"SEX&qu
9、ot;<<sex<<"AGE"<<age<<"SALARY"<<salary<<endl;4. Eixt(退出):利用exit來完成退出系統(tǒng)功能。四、設(shè)計和調(diào)試分析程序活單:#include<iostream.h>#include<stdlib.h>#include<fstream.h>#include<iomanip.h>#include<string.h>classemployeepublic:employee()sal
10、ary=0;voidpay()voidprint()voidinput()cout<<"ID:"cin>>no;cout<<"NAME:"cin>>name;cout<<"SEX(m/w):"cin>>sex;cout<<"AGE:"cin>>age;protected:intno;charname8;floatsalary;charsex;intage;;classmanager:virtualpublicemploy
11、eeprotected:floatmonthlypay,sale;public:manager()monthlypay=8000;voidinput()cout<<"Manger”;employee:input();voidsave()fstreamoutfile;outfile.open("f:flsdfj.txt”,ios:app);if(!outfile)cout<<"fcan'topen.n"abort();outfile<<"Manger"<<endl;outfile&
12、lt;<"ID"<<no<<"NAME"<<name<<"SEX"<<sex<<"AGE"<<age<<"SALARY"<<salary<<endl;voidpay()salary=monthlypay;voidprint()cout<<"|11111"<<endl;cout<<"I"<&l
13、t;setw(10)<<no<<"|"<<setw(10)<<name<<"I"<<setw(10)<<sex<<"|"<<setw(10)<<age<<"|"<<setw(10)<<salary<<"I"<<endl;classtechnician:virtualpublicemployeeprivate:float
14、hourlyrate;intworkhours;public:technician()hourlyrate=100;voidpay()cout<<name<<"Workhour:"cin>>workhours;salary=hourlyrate*workhours;voidinput()cout<<"TECHNICIAN"<<endl;employee:input();voidsave()fstreamoutfile;outfile.open("f:flsdfj.txt”,ios:ap
15、p);if(!outfile)cout<<"fcan'topen.n"abort();outfile<<"TECHNICIAN"<<endl;outfile<<"ID"<<no<<"NAME"<<name<<"SEX"<<sex<<"AGE"<<age<<"SALARY"<<salary<
16、<endl;voidprint()cout<<"|11111"<<endl;cout<<"|"<<setw(10)<<no<<"|"<<setw(10)<<name<<"I"<<setw(10)<<sex<<"|"<<setw(10)<<age<<"|"<<setw(10)<
17、<salary<<"I"<<endl;classsalesman:virtualpublicemployeeprotected:floatcommrate;floatsales;public:salesman()commrate=0.04;voidinput()cout<<"SALEMAN"employee:input();voidsave()fstreamoutfile;outfile.open("f:flsdfj.txt",ios:app);if(!outfile)cout<<
18、"fcan'topen.n"abort();outfile<<"TECHNICIAN"<<endl;outfile<<"ID"<<no<<"NAME"<<name<<"SEX"<<sex<<"AGE"<<age<<"SALARY"<<salary<<endl;voidpay()cout<&
19、lt;name<<"Salesvolume:"cin>>sales;salary=sales*commrate;voidprint()cout<<"|11111"<<endl;cout<<"|"<<setw(10)<<no<<"|"<<setw(10)<<name<<"I"<<setw(10)<<sex<<"|"
20、;<<setw(10)<<age<<"|"<<setw(10)<<salary<<”|"<<endl;classsalesmanager:virtualpublicmanager,virtualpublicsalesmanprivate:floattotal;intno1,no2,no3,no4;charname18,name28,name38,name48;floatsale1,sale2,sale3,sale4;public:voidsalemanager()monthlypa
21、y=5000;commrate=0.005;voidinput()(cout<<"Salesmanger"employee:input();voidsave()(fstreamoutfile;outfile.open("f:flsdfj.txt",ios:app);if(!outfile)(cout<<"fcan'topen.n"abort();outfile<<"Salesmanger"<<endl;outfile<<"ID"
22、<<no<<"NAME"<<name<<"SEX"<<sex<<"AGE"<<age<<"SALARY"<<salary<<endl;voidsavesale()(fstreamoutfile;outfile.open("f:flsdfj.txt",ios:app);if(!outfile)(cout<<"fcan'topen.n"abo
23、rt();outfile<<"Thesalaryofsalemanofsalesmangerandthemselves"<<endl;outfile<<"ID"<<no1<<"NAME"<<name1<<"SALARY"<<sale1<<endloutfile<<"ID"<<no2<<"NAME"<<name2<&l
24、t;"SALARY"<<sale2<<endlJoutfile<<"ID"<<no3<<"NAME"<<name3<<"SALARY"<<sale3<<endl;outfile<<"ID"<<no4<<"NAME"<<name4<<"SALARY"<<sale4<<e
25、ndl;voidpay()cout<<name<<"Thesalesvolumeofeverydepartment:"salary=monthlypay+commrate*total;floattotalsale()total=sale1+sale2+sale3+sale4;returntotal;voidprinttotal()cout<<"|1111"<<endl;cout<<"|Total|"<<setw(10)<<total<<&q
26、uot;I"<<endl;cout<<"111"<<endl;voidsort(salesmanagerp)inttmp,i,j;for(j=0;j<2;j+)for(i=0;i<2;i+)if(total<p.salary)tmp=salary;total=p.salary;p.salary=tmp;tmp=no;no=p.no;p.no=tmp;voidsaler()(cout<<"StaffID:"cin>>no1;cout<<"Staff
27、NAME:"cin>>name1;cout<<"Salesvolume:"cin>>sale1;cout<<"StaffID:"cin>>no2;cout<<"StaffNAME:"cin>>name2;cout<<"Salesvolume:"cin>>sale2;cout<<"StaffID:"cin>>no3;cout<<"Sta
28、ffNAME:"cin>>name3;cout<<"Salesvolume:"cin>>sale3;cout<<"StaffID:"cin>>no4;cout<<"StaffNAME:"cin>>name4;cout<<"Salesvolume:"cin>>sale4;voidsaleprint()cout<<"|"<<setw(10)<<no
29、1<<”|"<<setw(10)<<name1<<”|"<<setw(10)<<sale1<<"I"<<endl;cout<<"|111"<<endl;cout<<"|"<<setw(10)<<no2<<”|"<<setw(10)<<name2<<”|"<<setw(10)<&
30、lt;sale2<<”|"<<endl;cout<<"|111"<<endl;cout<<"|"<<setw(10)<<no3<<”|"<<setw(10)<<name3<<”|"<<setw(10)<<sale3<<”|"<<endl;cout<<"|111"<<endl;cout<&l
31、t;"|"<<setw(10)<<no4<<”|"<<setw(10)<<name4<<”|"<<setw(10)<<sale4<<”|"<<endl;voidprint()cout<<"|111H1"<<endl;cout<<"|"<<setw(10)<<no<<”|"<<setw(10)&l
32、t;<name<<”|"<<setw(10)<<sex<<"|"<<setw(10)<<age<<”|"<<setw(10)<<salary<<"|"<<endl;voidmain()managerm4;techniciant4;salesmans4;salesmanagersm4;t1.save();intflag=1,operate;docout<<"#Thesystemo
33、fsalarymanger#n"cout<<"i1n"cout<<"Choseyouractionsn"cout<<"Input:1,Entern"cout<<"Total:2,Entern"cout<<"Output:3,Entern"cout<<"Save:4,Entern"cout<<"Exit:5,Entern"cout<<"11n&
34、quot;cout<<"Pleasechoseoneaction:;cin>>operate;switch(operate)case1:cout<<"Waitingforaminute!"<<endl;for(inti=0;i<4;i+)mi.input();for(intj=0;j<4;j+)tj.input();for(intk=0;k<4;k+)sk.input();for(intl=0;l<4;l+)sml.input();for(inti=0;i<4;i+)mi.pay();f
35、or(intj=0;j<4;j+)tj.pay();for(intk=0;k<4;k+)sk.pay();for(intl=0;l<4;l+)sml.pay();sml.saler();break;case2:cout<<"Waitingforaminute!"<<endl;for(intl=0;l<4;l+)sml.totalsale();for(inti=0;i<4;i+)for(intj=0;j<2;j+)smj.sort(smj+1);cout<<"Thesalemanofthefir
36、stsalesmanger"<<endl;cout<<"i111<<endl;cout<<"|IDNAME|SALARY|<<endl;sm0.saleprint();sm0.printtotal();cout<<"Theorderiscomplete"<<endl;cout<<"Listnamesofeverysalesmanger"<<endl;cout<<"i111I1"<&
37、lt;endl;cout<<"|ID|NAME|SEX|AGEISALARY|"<<endl;for(intk=0;k<4;k+)smk.print();cout<<"111111"<<endl;break;case3:cout<<"Waitingforaminute!"<<endl;cout<<"Theblankofthe:"<<endl;cout<<"i111I1"<<endl;cout<<"|ID|NAME|SEX|AGEISALARY|"<<endl;for(inti=0;i<4;i+)mi.print();cout<<"111111"<<endl;
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 專題4.4 正弦定理和余弦定理及其應(yīng)用(原卷版)-2024年高考數(shù)學一輪復(fù)習精講精練寶典(新高考專用)
- 拉桿式雨棚施工方案
- 燃氣推廣知識培訓課件
- 2024年海南省中考滿分作文《點亮勤奮這盞燈》
- 農(nóng)村房間流轉(zhuǎn)合同范例
- 公司設(shè)備購貨合同范例
- 水利行業(yè)保安工作總結(jié)計劃
- 跨境電商倉儲管理的經(jīng)驗與反思計劃
- 第二章 第一節(jié) 二 緯線與緯度 經(jīng)線與經(jīng)度教學設(shè)計-2024-2025學年湘教版初中地理七年級上冊
- 八年級地理下冊 6.2 白山黑水 東北三省教學實錄 (新版)新人教版
- 近代德國的學前教育課件
- 球墨鑄鐵正火工藝
- 中國神經(jīng)外科重癥患者營養(yǎng)治療專家共識(2022版)課件
- 裝修項目經(jīng)理簡歷
- (完整版)管理學專業(yè)英語詞匯大全
- 《隆中對》教學講解課件
- 污水處理項目運營期績效考核評分表
- 蒙迪歐維修手冊
- 香味的分類(撲卻分類法)
- 鹽城市殘疾人康復(fù)機構(gòu)認定暫行辦法
- 大學生心理健康教育-大學生心理健康導(dǎo)論
評論
0/150
提交評論