小型公司工資管理系統(tǒng)設(shè)計(jì)面對(duì)對(duì)象課程設(shè)計(jì)_第1頁
小型公司工資管理系統(tǒng)設(shè)計(jì)面對(duì)對(duì)象課程設(shè)計(jì)_第2頁
小型公司工資管理系統(tǒng)設(shè)計(jì)面對(duì)對(duì)象課程設(shè)計(jì)_第3頁
小型公司工資管理系統(tǒng)設(shè)計(jì)面對(duì)對(duì)象課程設(shè)計(jì)_第4頁
小型公司工資管理系統(tǒng)設(shè)計(jì)面對(duì)對(duì)象課程設(shè)計(jì)_第5頁
已閱讀5頁,還剩32頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、械蝕2處摞濱江學(xué)院面向?qū)ο蟪绦蛟O(shè)計(jì)課程設(shè)計(jì)題 目小型公司工資管理系統(tǒng)設(shè)計(jì)院 系計(jì)算機(jī)系專 業(yè)計(jì)算機(jī)科學(xué)與技術(shù)學(xué)生姓名學(xué) 號(hào)指導(dǎo)教師二0六年十二月二十日1. 前言1.1選題目的及意義1.2研究內(nèi)容及要求2. 系統(tǒng)分析2. 1軟硬件環(huán)境及主要技術(shù)3. 系統(tǒng)概要設(shè)計(jì)3. 1系統(tǒng)總體架構(gòu)設(shè)計(jì)4. 系統(tǒng)詳細(xì)設(shè)計(jì)4. 1類的定義4. 2函數(shù)設(shè)計(jì)5. 系統(tǒng)實(shí)現(xiàn)5. 1類實(shí)現(xiàn)5. 2函數(shù)實(shí)現(xiàn)6. 系統(tǒng)測(cè)試6. 1模塊測(cè)試7. 收獲及體會(huì)參考文獻(xiàn)1前言11選題目的及意義以c+程序設(shè)計(jì)基礎(chǔ)為基礎(chǔ),進(jìn)行分析、編程、調(diào)試和運(yùn)行,進(jìn)一步掌 握而向?qū)ο蠛投蜻^程程序設(shè)計(jì)的基本方法和編程技巧,鞏固所學(xué)理論知識(shí),使 理論與實(shí)

2、踐相結(jié)合,提高分析問題、解決問題的能力。應(yīng)用2等內(nèi)容。2.2研究內(nèi)容及要求2.2.1問題描述 某公司需要存儲(chǔ)雇員的編號(hào)、姓名、性別、所在部門,級(jí)別,并進(jìn)行 工資的計(jì)算。其中,雇員分為經(jīng)理、技術(shù)人員、銷售人員和銷售經(jīng)理。四類人員的刀薪計(jì)算 方法如下:經(jīng)理拿固定月薪;技術(shù)人員按小吋領(lǐng)取月薪;銷售人員按其當(dāng)月銷售額的提成領(lǐng) 収工資;銷售經(jīng)理既拿固定月薪也領(lǐng)取銷售提成。設(shè)計(jì)一程序能夠?qū)救藛T進(jìn)行管理, 應(yīng)用到繼承、抽象類、虛兩數(shù)、虛基類、多態(tài)和文件的輸入/輸出等內(nèi)容。222功能要求:(1)添加功能:程序能夠任意添加上述四類人員的記錄,可提供選擇界面供用戶選擇 所要添加的人員類別。(2)查詢功能:可根

3、據(jù)編號(hào)、姓名等信息対已添加的記錄進(jìn)行查詢。(3)顯示功能:可顯示當(dāng)前系統(tǒng)中所有記錄。(4)編輯功能:可根據(jù)杳詢結(jié)果對(duì)和應(yīng)的記錄進(jìn)行修改。(5)刪除功能:主要實(shí)現(xiàn)對(duì)己添加的人員記錄進(jìn)行刪除。(6)統(tǒng)計(jì)功能:能根據(jù)多種參數(shù)進(jìn)行人員的統(tǒng)計(jì)。(7)保存功能:可將當(dāng)前系統(tǒng)中各類人員記錄存入文件中。(8)讀取功能:可將保存在文件屮的人員信息讀入到當(dāng)前系統(tǒng)屮,供川戶進(jìn)行使用。2系統(tǒng)分析2.1軟硬件環(huán)境及主要技術(shù)環(huán)境:visual c+ 6.0主要技術(shù):繼承、抽象類、虛函數(shù)、虛基類、多態(tài)和文件的輸入/輸岀等內(nèi)容3系統(tǒng)概要設(shè)計(jì)3.1整體架構(gòu)設(shè)計(jì)person 類廠一 sell類technician 類廠sell類

4、business 類bagman 類4系統(tǒng)詳細(xì)設(shè)計(jì)4.1類的定義雇員類:worker 經(jīng)理類:manager 技術(shù)人員類:technologyman 銷售人員類:salcman 銷售經(jīng)理類:salemanager 管理類:control4.2函數(shù)設(shè)計(jì)(1)定義各類的構(gòu)造函數(shù)(2)運(yùn)算符重載函數(shù)operator » > operator «,實(shí)現(xiàn)對(duì)對(duì)象的輸入輸出的重載。(3)輸入輸出函數(shù):display、input,實(shí)現(xiàn)對(duì)數(shù)據(jù)成員的輸入輸出。(4)計(jì)算工資函數(shù):money,實(shí)現(xiàn)對(duì)工資的計(jì)算。根據(jù)不同員工職務(wù)不同的計(jì)算方法。(5)修改雇員信息函數(shù):changeinform

5、ation,$現(xiàn)對(duì)雇員信息的修改管理。(6)添加屣員信息函數(shù):addinformation,現(xiàn)對(duì)屣員信息的添加管理。(7)計(jì)算雇員工資信息函數(shù):countinformation,實(shí)現(xiàn)對(duì)雇員工資信息的計(jì)算管理。(8)刪除雇員信息函數(shù):cancelinformation,實(shí)現(xiàn)對(duì)雇員信息的刪除管理。(9)查詢雇員信息函數(shù):searchinformation,實(shí)現(xiàn)対雇員信息的查詢管理。(10)顯示屣員信息函數(shù)(11)讀入屣員信息函數(shù)(12)保存雇員信息函數(shù)(13)統(tǒng)計(jì)雇員信息函數(shù)showinformation,實(shí)現(xiàn)對(duì)雇員信息的顯示管理。 readinformation,實(shí)現(xiàn)對(duì)屣員信息的讀入管理。 ke

6、epin formati on,實(shí)現(xiàn)對(duì)雇員信息的保存管理。 tongjiin formation,實(shí)現(xiàn)對(duì)雇員信息的統(tǒng)計(jì)管理。5系統(tǒng)實(shí)現(xiàn)5.1類的實(shí)現(xiàn)(1)雇員類/基類,員工class workerpublic:worker() count+;)worker(int mark)this->mark=mark;count+;virtual worker() cout«u員工類被析構(gòu);h«endl;jfriend istream& operator »(istream& in,worker& w)friend ostcam& ope

7、rator «(ostrcam& outworker& w);static int display 1()return count;void input();virtual void inputmoncyo;virtual void displayo;virtual void display2()=0;virtual void money()=0;char *getjibie()return jibic;)double getworktime()return worktime;double getxiaoshoue()return xiaoshoue;worker *

8、 next;int num;char name20j;char sex5j;char branch 20;/部門char jibic20;int mark;static int count,counthcount2,count3,count4,count5,count6;int basic;double worktime;double xiaoshouc;int job; 職務(wù);(2) 經(jīng)理類class manager:virtual public worker經(jīng)理public:manager()manager(int mark):worker(mark)m anagcr() cout

9、1;"經(jīng)理類被析構(gòu);"«endl;friend istream& operator »(istream& in,manager& w) friend ostream& operator «(ostream& oumanager& w); void inputmoneyo job= 1;cout«m請(qǐng)輸入職員基本工資:"«endl;cin»basic; count3+;void display2()cout«"職務(wù):經(jīng)理 職員基本工資:&q

10、uot;«cndl; cout«basic;void money()cout«h該員工的實(shí)際工資是:m«basic«endl;;(3) 技術(shù)人員類class technologyman:virtual public worker技術(shù)人員public:tcchnologyman()technologyman(int mark):worker(mark) -technologyman() cout«"技術(shù)人員類被析構(gòu);"«endl;void inputmoneyo job=3;cout«"

11、請(qǐng)輸入職員工作時(shí)間:"«endl;cin» work time; count5+;void display2()cout«"職務(wù):技術(shù)人員 職員工作時(shí)間:"«endl; cout«worktime;) void money() jine=35;cout«"該員工的實(shí)際工資是:h«(jine*worktinie)«endl; friend istream& operator »(istream& in,technologyman& w) fri

12、end ostream& operator «(ostream& oulcchnologyman& w); int jinc; ;(4) 銷售人員類class saleman:virtual public worker 銷偉人員public:saleman() salcman(int mark):workcr(mark) saleman() cout«"銷售人員類被析構(gòu);"«endl; void inputmoneyo job 二 2;cout«n請(qǐng)輸入職員銷售額:h«endl; cin»x

13、iaoshoue; ount4+; oid display2()coutvv"職務(wù):銷售人員職員銷售額:u«endl; cout«xiaoshoue;void money()tichengbili=0.05;cout«"該員工的實(shí)際工資是:"«xiaoshoue*tichengbili«endl; friend istrcam& operator »(istrcam& in,salcman& w)friend ostream& operator «(ostream

14、& out,saleman& w);double tichengbili; ;(5) 銷售經(jīng)理類class salcmanagcr: public manager, public salcman銷售經(jīng)理 public:salemanager()salemanager(int mark):worker(mark)salemanager() cout«'r銷售經(jīng)理類被析構(gòu);"«endl;void inputmoneyojob=4;cout«"請(qǐng)輸入職員基本工資,銷售額:"«endl;cin»ba

15、sic»xiaoshoue;count6+;1void display2()cout«h職務(wù):銷售經(jīng)理職員基本工資,銷售 額:”vvendl; cout«basic«m h«xiaoshoue; void money()tichengbili=0.03;cout«m 該員工的實(shí)際工資是:h«basic+xiaoshoue*tichengbili«endl;friend istream& operator »(istream& in,salemanager& s)friend ost

16、ream& operator «(ostream& out,salemanager& s); ;(6) 管理類class control private:worker *head; public:control() head二null;control。worker* p=null;p=hcad;while (p!=null) p=p->next; 指向下一個(gè)節(jié)點(diǎn)delete head; 釋放空間head=p; hcad=null;void showface();void changeinfoimation();修改void cancelinformati

17、on();/刪除void addinformation(); 添加void showinformation(); 顯示void searchinformation(); / 查詢void countinformation(); 計(jì)算void readinformation(); / 讀入void keepinformation(); 保存void tongjifbrmationo; 統(tǒng) 計(jì);5.2函數(shù)實(shí)現(xiàn)(1) 雇員類int worker:count 1=0; int worker:count2=0; int worker:count3=0; int worker:count4=0 ;int

18、worker:count5=0; int worker:count6=0; void worker:input() cout«n請(qǐng)輸入職員信息:u«endl;cout«u 編號(hào):"cin»num;cout«m 姓名:“;cin»name;int i;cout«n 性別:“;whilc( i=l) cin»sex;if(strcmp(sex/nanu)=o|strcmp(sex,h nv u)=0) if(strcmp(sex/nanf,)=o)count 1+; elsecount2+;break;els

19、e cout«'r輸入錯(cuò)課請(qǐng)重新輸ah«endl;)cout«h 部門:”;cin»branch;void worker:inputmoney()cout«m 基本工資:h«endl;cin»basic;void worker:display()cout«h 編 號(hào):n«num«h u«n 姓 名:',«namc«" "«n 性另i:h«scx«h u«h 部 n:u«branch

20、;)istream& openitor »(istream& in,worker& w)w.input();w.inputmoneyo;return in;)ostream& operator «(ostream& outworker& w)w.displayo;w.display2();w.moneyo;return out;(2) 經(jīng)理類istream& operator »(istream& in,manager& w)w.input();w.inputmoneyo;return in;

21、ostream& operator «(ostream& out, manager& w) w.displayo;w.display2();w.moncyo;return out;(3) 技術(shù)人員類istream& operator »(istream& inechnologyman& w) w.input();w.inputmoneyo;return in;ostream& operator «(ostream& out,technologyman& w) w.displayo;w.disp

22、lay2();w.moneyo;return out;(4) 銷售人員類istream& operator »(istream& insaleman& w)w.input();w.inputmoneyo;return in;ostream& operator «(ostream& out,saleman& w) w.displayo;w.display2();w.moneyo;return out;(5) 銷售經(jīng)理類istream& operator »(istream& in.salemanager

23、& s) s.input();s.inputmoneyo;return in;ostream& operator «(ostream& out,salemanager& s) s.displayo; s.display2();return out;(6) 管理類void menu()菜單函數(shù)cout«h 小型公司丁資管理系統(tǒng) m«endl;cout« 1| «cndl;cout«h 1請(qǐng)選擇您所需的操作i "«endl;cout«" 1數(shù)據(jù)輸入:1,并按回乍鍵;i

24、 n«endl;cout«m 1數(shù)據(jù)統(tǒng)計(jì):2,并按回車鍵;| u«endl;cout«n 1數(shù)據(jù)打印:3,并按回車鍵;i u«endl;cout«n 1數(shù)據(jù)查詢:4,并按回車鍵;i u«cndl;cout«h 1數(shù)據(jù)備份:5,并按回車鍵;| u«endl;cout«m 1退岀系統(tǒng):0,并按回午鍵;i n«endl;cout«n 11 h«endl;cout«"請(qǐng)選擇一個(gè)操作:”;void menu2()數(shù)據(jù)輸入二級(jí)菜單函數(shù)cout«h小

25、型公司工資管理系統(tǒng)m«endl;cou【w 廠cout«h 1請(qǐng)選擇您所需的操作i "«endl;cout«h 1經(jīng)理數(shù)據(jù)輸入:1,并按冋車鍵i "«endl;cout«" 1技術(shù)員數(shù)據(jù)輸入:2,并按回車鍵| "«endl;cout«m 1銷售員數(shù)據(jù)輸入:3,并按回車鍵| "«endl;cout«n 1銷售經(jīng)理數(shù)據(jù)輸入:4,并按回乍鍵| ”vvcndl;cout«n 1cout«h 1返回上一級(jí):5,并按回車鍵i h«

26、;cndl; 1 r «endl;cout«m請(qǐng)選擇一個(gè)操作:"void menu3()cout«h小型公司工資管理系統(tǒng)n«endl;廠 enai,cout«h 1請(qǐng)選擇您所需的操作i "«endl;cout«h 1經(jīng)理數(shù)據(jù)打印:1,并按回車鍵i "«endl;cout«" 1技術(shù)員數(shù)據(jù)打?。?,并按回車鍵| "«endl;cout«m 1銷售員數(shù)據(jù)打印:3,并按回車鍵| "«endl;cout«m 1銷售

27、經(jīng)理數(shù)據(jù)打印:4,并按回車鍵| h«endl;cout«n 1返回上一級(jí):5,并按回車鍵| h«cndl;cout«jjeikh;cout«m請(qǐng)選擇一個(gè)操作:”;數(shù)據(jù)打印二級(jí)菜單函數(shù)void data_input()數(shù)據(jù)輸入函數(shù)char p;int i;mcnu2();for(intj=0;j<100;j+)cin»p;if(p='5,) break;elseswitch(p)case* l1:for(i=0;i<n2;i+)mi.input();cout«endl«nh«endl;m

28、enu2();break;case2:fbr(i=o;i<nl;i+)ti.input();cout«endl«mh«endl;menu2();break;case'3':fbr(i=0;i<n3;i+)siinpih(); cout«cndl«h,«cndl;mcnu2();brcak;case4:for(i=0;i<n4;i+)smi.input();cout«endl«n-m«endl;menu2();break;void charthead 1 ()制表頭1 (數(shù)

29、據(jù)統(tǒng)計(jì)用)cout«" |111 "«endl;cout«n |職工號(hào)|姓名|銷售額| u«endl;void charthead2() 制表頭2 (數(shù)據(jù)打印及銷售經(jīng)理數(shù)據(jù)統(tǒng)計(jì)用)cout«" iiiiii"«endl;cout«h |職工號(hào)| 姓名| 性別| 年齡| 工資ih«endl;void chartend() 制表尾(數(shù)據(jù)打印及銷售經(jīng)理數(shù)據(jù)統(tǒng)計(jì)用)cout« 111111 ”;void statistics()數(shù)據(jù)統(tǒng)計(jì)函數(shù) int i,j;for(i=0;

30、i<n4;i+) double sum=0;cout«endl«m職 ii號(hào)為"vvsmi.sm_numbei*()vv” 銷售經(jīng)理"«smi.sm_name()«"下屬銷售員的業(yè)績?yōu)?h«cndl«cndl;charthcadl();for(j=0;j<n3;j+)if(sjj.s _n umber()二二mbe()sum=sum+sfj.amount();s|j.gradc();cout«n |111 u«endl;cout«n | 銷售額總計(jì) | ”vvse

31、tw(12)vvsumvv“| h«endl;cout«h 111 n«endl;double salaryln4j;double sm_salary()銷售經(jīng)理工資計(jì)算及排序int i,j;double a ;sell_manager b; for(int k=0;k<n4;k+)salaryk=o;for(i=0;i<n4;i+) double sum=0;for(j=0;j<n3;j+)if(sj.s_number()=smi.sm_number() sum=sum+sj.amount();salaryi=sum*sm_proportion

32、+basicpay;for(j=0;j<n4-l;j+)for( i=0;i<n4-l-j;i+)if(salaryi<salaryi+1) a=salaryi+1 j;salaryi+l=salaryi;salaryij=a; b=smi+ l;smi+ lj=smij;smij=b;return 0;void sm_print()sm_salary();charthead2();for(int i=0;i<n4;i+) smi.print();cout«setw(7)«salaryli«n | m«endl;chartcnd(

33、);cout«endl;void data_print() 數(shù)據(jù)打印char p;int ij;menu 2();for(j=0;j< 100;j+)cin»p;if(p=3)break;elseswitch(p)經(jīng)理信息casct:cout«endl«m 經(jīng)理"«endl;charthead2();for(i=0;i<n2;i+)mi.print();chartend();cout«endl«endl<<"m«endl;mcnu3();brcak;case'2&

34、#39;:cout«endl«m技術(shù)員u«endl;技術(shù)員信息charthead2();for(i=0;i<nl;i+)ti.print();chartend();cout«endl«endl«m"«endl;menu3();break;case'3*:cout«endl«m銷售員"«endl;銷售員信息cout«" |iiiii1 "«endl;cout«n |職工號(hào)|姓名|性另ij |年齡| 工資i 所屬部門

35、經(jīng)理編號(hào) i “vvcndl;for(i=0;i<n3;i+)si.print();cout«n 111111cout«cndl«cndl«hmenu3();break;case4:cout«endl«m銷售經(jīng)理u«endl;銷偉經(jīng)理信息sm_salary(); sm_print();m«endl«endl;cout«endl«endl«mmenu3();break;)1void data_find() 數(shù)據(jù)查詢函數(shù)for(int i=0;i<nl;i+) ti.

36、find();for(i=0;i<n2;i+)mi.find();for(i=0;i<n3;i+)si.find();for(i=0;i<n4;i+)if(cname=smfi.sm_name() charthcad2();smi.print();cout«setw(7)«salaryi«h | "«endl;chartend();cout«endl;break;void data_save() 數(shù)據(jù)備份函數(shù)outfile«endl«"技術(shù)員"«endl;技術(shù)員信息o

37、utfile«" |11111"«endl;outfile«h |職工號(hào)|姓名|性別|年齡| 工資in«endl;for(int i=();i<n 1 ;i+)ti.savc();outfile«h 111111 “;outfile«endl«endl<<""«endl;outfilc«cndl«h 經(jīng)理 h«cndl;經(jīng)理信息outfile«m |11111"«endl;outfile«

38、h |職工號(hào)|姓名|性別|年齡| 工資ih«endl;for(i=0;i<n2;i+)mi.savc();outfile«h 111111 “;outfile«endl«endl«hh«endl;outfile«endl«"銷售經(jīng)理"«endl;銷售經(jīng)理信息sm_salary();outfile«m |11111n«endl;outfilc«h |職工號(hào)|姓名|性別i年齡i 工資i ” vvcndl;for(i=0;i<n4;i+) smij.

39、save();outfile«setw(7)«salaryi«m | m«endl;)outfile«h 111111 “;outfile«endl«endl«"n«endl«endl;outfile«endl«"銷售員"«endl;銷售員信息outfile«" |111111 "«endl;outfile«h |職工號(hào)|姓名|性別|年齡 | 工資i 所屬部門經(jīng)理編號(hào)i “vvcndl;

40、for(i=0;i<n3;i+)si.save();outfile«h 111111outfile«endl«endl«h cndl;6系統(tǒng)測(cè)試6模塊測(cè)試 添加 ; ef itui - mu - *11mil - 2 uuvujimjxj 作車車車車車車 操回回回回回回 的: 所2,3,4,5,0. x x 擇入計(jì) 選舅打查篥 in 數(shù)數(shù)數(shù)數(shù)數(shù)la s2 s2 ta請(qǐng)選擇一個(gè)操作江您所選揀作為數(shù)據(jù)輸入.溝繼續(xù)一小型公司工資簣理系統(tǒng)車車車車車覆回回回一回回-us * 1 2 3 4 5 所入, 您入入輸 擇入 選數(shù)級(jí) 屠數(shù)數(shù)理一 n± 理術(shù)

41、產(chǎn)ii回1作操個(gè):lon:2nvj 一號(hào)ha>:號(hào)ia>:nzw扁 q m 選的名5:2的名5:2 請(qǐng)理姓別齡理姓別齡 經(jīng)歪年經(jīng)歪年小型公司工資管理系統(tǒng)mw建違建 車車車車車 回回回回回 i1s12 3 4 5 需:所 入 您入入輸級(jí) 請(qǐng)據(jù)數(shù)數(shù)理一 數(shù)©菇上 理術(shù)隹足口回 經(jīng) t 2 作 操:1 個(gè)號(hào) 一編2號(hào),5扁 : 1>9 間的:1w2司fi.fr ; 9>-±-由;6 代 名5:2甘貝名5:2時(shí) 棗姓別齡槩姓別齡作 技耀甲工按耀年工車車車車車 回回回回回 的2,3,4,5, 需 所 入 邂入入寵 擇入選數(shù)級(jí) 請(qǐng)據(jù)數(shù)數(shù)理一 數(shù)口囚易上 理術(shù)童星

42、口回 經(jīng):操:1 個(gè)號(hào)u 一編ho 篇:z 選員名為3p理號(hào) 0kh扁 2:3伍咼:2額闔名5:2額屠名5:3額魁貝名5:3額銷炷窿0別w:別:皆娃別斷壬010口姓別齡勺2 0 3 0kh 扁 i>:3 繪u 7 8:2h£:w/w9號(hào)編0 4m 0理號(hào)gm: 3 kh 扁 n :> a > /w1:2隹 :w/wl小型公司工資管理系統(tǒng)回旦旦旦回的1.2,3,4,5, -v*vc. fills 所 入 您入入輸 擇入選數(shù)級(jí) 請(qǐng)據(jù)數(shù)數(shù)理一 數(shù)0囚豈上 理術(shù)盧口回 經(jīng)個(gè)編一的al擇理:b選經(jīng)名請(qǐng)隹雄別齡隹尿別齡1j- : / s3經(jīng)名5 :杳詢請(qǐng)選擇一個(gè)操作:5小型公司

43、工資管理系車槌,車槌車檢;車槌'丄青連塔您所 榔:二 tlti: i:誦選擇一個(gè)操作汐 您所選操作為數(shù)據(jù)統(tǒng)計(jì),請(qǐng)繼續(xù)一 職工號(hào)為1銷售經(jīng)理bai下厲銷善員的業(yè)績?yōu)?職工號(hào)姓名銷售額11zhou23003zheng2930銷售額總計(jì)5230職工號(hào)為2銷售經(jīng)理w下屬銷售員的業(yè)績?yōu)槎樵兟毠せ厩闆r一覽表如下:小型公司工資管理系統(tǒng)*經(jīng)理數(shù)據(jù)輸入ips理穀堵輸入 逍回上一級(jí)請(qǐng)選擇一個(gè)操作汚 一數(shù)據(jù)打印完畢一小型公司工資管理系統(tǒng)請(qǐng)選擇一個(gè)操作:4 眉所選操作為數(shù)據(jù)查詢,請(qǐng)繼續(xù)一 討輸入您要查詢的職工姓名:sun-正在查詢,請(qǐng)等待- b查詢的信息如下:職工號(hào)姓名性別年齡工資1sunm290保存3

44、二 一 311ma -umuumm. fmmmn>h 作車車車車車車$12 3 4 5 0您 !1擇入計(jì) 選鳥丁暨備據(jù)據(jù)據(jù)據(jù) 數(shù)數(shù)數(shù)數(shù)請(qǐng)選擇一個(gè)操作:5您所選操作為數(shù)據(jù)備份,請(qǐng)繼續(xù)一數(shù)據(jù)備份完成,請(qǐng)繼續(xù)一小型公司工資管理系統(tǒng)請(qǐng)選擇一個(gè)操作詢您所選操作為退出系統(tǒng),請(qǐng)確認(rèn)一是< y > 否< n > y請(qǐng)按任意鍵退岀系統(tǒng)一press any key to continue7收獲及體會(huì)從網(wǎng)上找了一些相類似的程序,口己開始看模仿,有一部分上網(wǎng)查詢,翻翻書,使我的 只是增長不少。運(yùn)行時(shí)也有一些錯(cuò)誤,対于每個(gè)問題都查詢資料,最后還是都解決了。經(jīng)過 這一次學(xué)習(xí),讓我的編程能力有

45、了一定的提高。參考文獻(xiàn):1 高俊文。c/c+程序設(shè)計(jì)。北京:人民郵電出版社,20052 譚浩強(qiáng)。c+程序設(shè)計(jì)。北京:清華大學(xué)出版社,20043 bartosz milewski,周良忠。c+實(shí)踐之路。北京:人民郵電出版社,20024 譚浩強(qiáng)。c語言程序設(shè)計(jì)(第2版)。北京:清華大學(xué)出版社,2003附錄源程序:#include<fstream># include<iostream># include<string>#includc<iomanip>#include<stdlib.h>using namespace std;常變量(供修改

46、用):const int nl=2,n2=2,n3=4,n4=2;/*定義公司各類職工人數(shù)(方便修改)(nl:技術(shù)員人數(shù);n2:經(jīng)理人數(shù):n3:銷售員人數(shù);n4:銷售經(jīng)理人數(shù))勺const double m_salary=8000;經(jīng)理固定刀工資const double hourpay=100;技術(shù)員小時(shí)工資const double basicpay=5000;銷售經(jīng)理的底薪const double s_proportion=4.0/100; 銷售員的工資提成比例const double sm_proportion=0.5/100; 銷偉經(jīng)理的提成比例聲明部分: void menu();主菜單

47、void mcnu2();void menu3();void data_input(); void data_print();void charthead 1();數(shù)據(jù)輸入二級(jí)菜單數(shù)據(jù)打卬二級(jí)菜單數(shù)據(jù)輸入函數(shù)數(shù)據(jù)打印制作表頭1函數(shù),統(tǒng)計(jì)銷偉額void charthead2(); void chartend();void statistics();制作表頭2函數(shù),數(shù)據(jù)打印制作表尾數(shù)據(jù)統(tǒng)計(jì)double sm_salary(); 銷售經(jīng)理工資計(jì)算void sm_print(); void data_find(); void data_save();銷售經(jīng)理打印數(shù)據(jù)數(shù)據(jù)查詢數(shù)據(jù)備份ofstream o

48、utfile; /打開磁盤文件流對(duì)象string f_name;全局變量(查詢川)定義類:class employee雇員類(基類)public:void input()數(shù)據(jù)輸入函數(shù)cout«"編號(hào):"; cin»num; cout«h其姓名:”; cin» name;cout«h 性另 ij(m/w):m;cin»sex;coutvv”年齡:”;cin»age;void print()打印數(shù)據(jù)函數(shù)cout«" |111cout«h | ,«sctw(6)«

49、;num«n| n«sctw(8)«namc«ni h«setw(6)«age«"| ',«setw(7)«pay«"| "«endl;void find()查詢函數(shù)if(flnamc=namc)charthead2();print();chartend();cout«cndl;void save()備份數(shù)據(jù)函數(shù)1 "vendl;| m«sctw(6)«scx«noutfile«u |11

50、1"«endl;outfile«u | n«setw(6)«num«n| n«setw(8)«name«ni n«setw(6)«age«m | u«setw(7)«pay«h | u«endl;+ti n«setw(6)«sex«nprotected:int num; /職工號(hào) string name;職工姓名char sex;職工性別int age;職工年齡double pay; 職匸-資class t

51、echniciampublic employee技術(shù)員類(公有繼承)public:void input()cout«"技術(shù)員的"; employee:input();cout«"工作時(shí)間:”; cin»worktimc;void print() pay=worktime*hourpay;employee: :print();void find()employee:find();void savc() pay=worktime*hourpay;employee: :save();(小時(shí))經(jīng)理類protected:double workt

52、ime; 工作吋間;class manager:public employeepublic:void input()cout«n經(jīng)理的“;employee:input();void print() pay=m_salary;employee: :print();void find()employee:find();void savc() pay=m_salary;employee: :save();class sell_manager:public employee 銷售經(jīng)理類public:void input() cout«h銷售經(jīng)理的”;employee:input()

53、;int sm_numbcr()調(diào)用銷售經(jīng)理職工號(hào)return num;string sm_name() 調(diào)用銷售經(jīng)理姓名return namc;void print()1 ,f«endl;i h«setw(6)«sex«mi m«setw(6)«sex«mcout«" i111cout«" | "<<setw(6)«num«"| "«setw(8)<ame«u| n«setw(6)

54、71;age«h 丨“;void save()outfile«n |111h«endl;outfile«u | "<<setw(6)«num«"| "<<setw(8)«name«"i n«setw(6)«age«" | n;;class seller:public employee銷售員類public:seller() sold_amount=0;) 構(gòu)造函數(shù),銷售額初始化為0void input()coutv

55、v銷售員的”;employcc:input();cout«h銷售額:”;cin»sold_amount;coutvv”所屬銷售經(jīng)理的編號(hào):”;cin»nu;void grade()銷售員業(yè)績輸出cout«n |111 h«endl;cout«" | ”<<sctw(6)v<num<v"|"<<sctw(8)«namc«"|"«setw(7)«sold_amount<<" | "&

56、#171;endl;void print() pay=sold_amount*s_proportion;cout«h |111111 h«endl;cout«" | "vvse(w(6)v<num«"| ,«setw(8)«name«u | ,«setw(6)«sex«h| n«setw(6)«agc«" | "<<sctw(7)«pay«"| "«

57、sctw(13)«nii«h| "«cndl;int s_number()調(diào)用銷售員所屬銷售經(jīng)理職工號(hào)return nu;double amount()調(diào)用銷售員銷售額return sold_amount;void find() if(cnamc=namc)cout«" |iiill1 n«endl;cout«" |職工號(hào)|姓名|性別|年齡| 工資| 所屬 部門經(jīng)理編號(hào) i "«cndl;print();cout«n "«endl;11111void sa

58、vc() pay=sold_amount*s_proportion;outfile«" |1outfile«h | "«setw(6)«num«"| ”vvsetw(8)vvnamevv" | u«setw(6)«sex«ni n«setw(6)«age«h | n«setw(7)«pay«n | n«setw(13)«nu<<n| u«endl;protected:doub

59、le sold_amount; 銷售額int nu;所屬銷售經(jīng)理職工號(hào);定義全局對(duì)象數(shù)組technician tnl;技術(shù)員manager mn2j;經(jīng)理seller sn3;銷售員sell_manager smn4;銷售經(jīng)理(卜屬若t銷售員)/主函數(shù)部分:int main()char n;menu();for(int i=0;i<1000;i卄)設(shè)定循環(huán)次數(shù)(便各項(xiàng)操作的切換及方便查詢)cin»n;switch(n)case'l':數(shù)據(jù)輸入cout«endl«u您所選操作為數(shù)據(jù)輸入,請(qǐng)繼續(xù)-"«endl«end

60、l;data_i nput();cout«endl;menu();break;case'2':數(shù)據(jù)統(tǒng)計(jì)cout«endl«h您所選操作為數(shù)據(jù)統(tǒng)計(jì),請(qǐng)繼續(xù)-m«endl«endl;statistics();cout«endl«,'銷售經(jīng)理按工資排序?yàn)?,'«'n'«cndl;sm_print();cout«endl;menu();break;case'3':數(shù)據(jù)打印cout«endl«h您所選操作為數(shù)據(jù)打印,請(qǐng)繼續(xù)-m«endl«endl;cout«,a'«h數(shù)據(jù)打印中,請(qǐng)等待“vvwvvg'vvendl;cout«&

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論