1、#include#include#include#includeconst int TMAX=50;using namespace std;class Personpublic:int num;/编号string name;/姓名string sex;/性别int age;/年龄double water;/用水量double power;/用电量public:Person(int n=0,string nm=“ “,string s=“ “,int a=0,double w=0.0,double p=0.0)/初始化num = n;name = nm;sex = s;age = a;water
2、 = w;power = p;virtual void Input();virtual void Output();int GetNum()return num;/获取编号string GetName()return name;/获取姓名double GetWater()return water;/获取用水量double GetPower()return power;/获取用电量;class Teacher:virtual public Person /教师public:string depart;/工作部门double watermoney;/教师水费double powermoney;/教
3、师电费int choice1;int choice2;public:Teacher(int n=0,string nm=“ “,string s=“男“,int a=0,string d=“普通教师“,double w=0.0, double p=0.0, double wm=0.0, double pm=0.0):Person(n,nm,s,a,w,p),depart(d)/构造函数watermoney=wm;powermoney=pm;void Input()coutnum;coutname;coutchoice2;switch(choice2)case 1:sex=“男“;break;c
4、ase 2:sex=“女“;break;default:coutage;coutchoice1;switch(choice1)case 1:depart=“普通教师“;break;case 2:depart=“教务处“;break;case 3:depart=“财政处“;break;case 4:depart=“创业办公室“;break;default:coutwater;coutpower;watermoney=0.5*water;powermoney=0.5*power;void Output()coutnum;coutname;coutchoice2;switch(choice2)cas
5、e 1:sex=“男“;break;case 2:sex=“女“;break;default:coutage;coutchoice1;switch(choice1)case 1:bj=“计科 1 班“;break;case 2:bj=“计科 2 班“;break;case 3:bj=“计科 3 班“;break;case 4:bj=“计科 4 班“;break;default:coutwater;coutpower;watermoney=0.5*(water-10);powermoney=0.5*(power-10);void Output()cout=TMAX) coutchoice;swi
6、tch(choice)case 1:coutname;coutwater;coutpower;coutnum;for(int i=0;ichoice; switch(choice)case 1:coutnum;for(int i=0;ichoice;switch(choice)case 1:for(int j=i;jname;for(int i=0;ichoice;switch(choice)case 1:for(int j=i;jchoice;switch(choice)case 1:double zwater=0.0, zpower=0.0;for(int i=0; iStui.numSt
7、ui.nameStui.sexStui.ageStui.bjStui.waterStui.powerStui.watermoneyStui.powermoney)i+;top+;cout=TMAX) coutchoice;switch(choice)case 1:coutname;coutwater;coutpower;coutnum;for(int i=0;ichoice; switch(choice)case 1:coutnum;for(int i=0;ichoice;switch(choice)case 1:for(int j=i;jname;for(int i=0;ichoice;sw
8、itch(choice)case 1:for(int j=i;jchoice;switch(choice)case 1:double zwater=0.0, zpower=0.0;for(int i=0; iTeai.numTeai.nameTeai.sexTeai.ageTeai.departTeai.waterTeai.powerTeai.watermoneyTeai.powermoney)i+;top+;cout教师水电费管理 t2=学生水电费管理 t0=退出系统 “choice;switch(choice) case 1:TeaMenu();break;case 2:StuMenu()
9、;break;case 0:coutchoice;switch(choice)case 1:t.Add();break;case 2:t.Search();break;case 3:t.Edit();break;case 4:t.Delete();break;case 5:t.Show();break;case 6:t.Save();break;case 7:t.Read();break;case 8:t.Total();break;case 0:coutchoice;switch(choice)case 1:s.Add();break;case 2:s.Search();break;case 3:s.Edit();break;case 4:s.Delete();break;case 5:s.Show();break;case 6:s.Save();break;case 7:s.Read();break;case 8:s.Total();break;case 0:cout“退出成功!“endl;break;default:cout“无此选项!请重试!“endl;break;