資源描述:
《C++課程設計高校水電費管理系統(tǒng)》由會員上傳分享,免費在線閱讀,更多相關內(nèi)容在行業(yè)資料-天天文庫。
1、#include#include#include#includeconstintTMAX=50;usingnamespacestd;classPerson{public:intnum;//編號stringname;//姓名stringsex;//性別intage;//年齡doublewater;//用水量doublepower;//用電量public:Person(intn=0,stringnm="",strings="",inta=0,doublew=0.0,doublep=0.0
2、)//初始化{num=n;name=nm;sex=s;age=a;water=w;power=p;};virtualvoidInput(){};virtualvoidOutput(){};intGetNum(){returnnum;}//獲取編號stringGetName(){returnname;}//獲取姓名doubleGetWater(){returnwater;}//獲取用水量doubleGetPower(){returnpower;}//獲取用電量};classTeacher:virtualpublicPerson//教師{public:str
3、ingdepart;//工作部門doublewatermoney;//教師水費doublepowermoney;//教師電費intchoice1;intchoice2;public:Teacher(intn=0,stringnm="",strings="男",inta=0,stringd="普通教師",doublew=0.0,doublep=0.0,doublewm=0.0,doublepm=0.0):Person(n,nm,s,a,w,p),depart(d)//構造函數(shù){watermoney=wm;powermoney=pm;};voidInput(
4、){cout<<"請輸入編號:"<>num;cout<<"請輸入姓名:"<>name;cout<<"請選擇性別:";cout<<"(1.男2.女)"<>choice2;switch(choice2){case1:sex="男";break;case2:sex="女";break;default:cout<<"輸入錯誤。"<>age;cout<<"請選擇工作部門:"<5、cout<>choice1;switch(choice1){case1:depart="普通教師";break;case2:depart="教務處";break;case3:depart="財政處";break;case4:depart="創(chuàng)業(yè)辦公室";break;default:cout<<"輸入錯誤。"<6、out<<"請輸入本月的用水量"<>water;cout<<"請輸入本月的用電量"<>power;watermoney=0.5*water;powermoney=0.5*power;}voidOutput(){cout<<""<7、tualpublicPerson//學生{public:stringbj;//學生班級doublewatermoney;//學生水費doublepowermoney;//學生電費intchoice1;intchoice2;public:Student(intn=0,stringnm="",strings="男",inta=0,stringz="",doublew=0.0,doublep=0.0,doublewm=0.0,doublepm=0.0):Person(n,nm,s,a,w,p),bj(z)//構造函數(shù){watermoney=wm;powermo
8、ney=pm;};voidInput(){cout<<"請輸入學號:"<