实验一:第三章类与对象定义一个学生类,进行成绩管理,显示学生的所有信息。#includeiostream#includestringusingnamespacestd;classStudent{private:charname[10],*snumber;doublemath,eng,computer;public:Student(char*n,char*s,doublem,doublee,doublec){strcpy(name,n);snumber=s;math=m;eng=e;computer=c;}voidavescore(){doubleave;ave=(math+eng+computer)/3.0;cout姓名:nameendl;cout学号:snumberendl;cout数学:mathendl;cout英语:engendl;cout计算机:computerendl;cout平均成绩:aveendlendl;}};voidmain(){Studentx(张三,200701,80,85,87),y(李四,200702,75,80,79),z(王五,200703,85,90,77);x.avescore();y.avescore();z.avescore();}实验二:第三章类与对象课后习题10:某单位的职工工资包括基本工资Wage,岗位津贴Subsidy,房租Rent,水费WaterFee和电费ElecFee。设计实现工资管理的类Salary。其中:实发工资Wage+Subsidy-Rent-WaterFee-ElecFee#includeiostream#includestringusingnamespacestd;classSalary{private:doubleWage,Subsidy,Rent,WaterFee,ElecFee;public:Salary(doublea,doubleb,doublec,doubled,doublee){Wage=a;Subsidy=b;Rent=c;WaterFee=d;ElecFee=e;}Salary(){Wage=0;Subsidy=0;Rent=0;WaterFee=0;ElecFee=0;}voidsetWage(doublef){Wage=f;}getWage(){returnWage;}voidsetSubsidy(doublef){Subsidy=f;}getSubsidy(){returnSubsidy;}voidsetRent(doublef){Rent=f;}getRent(){returnRent;}voidsetWaterFee(doublef){WaterFee=f;}getWaterFee(){returnWaterFee;}voidsetElecFee(doublef){ElecFee=f;}getElecFee(){returnElecFee;}voidRealSalary(){doublerealsalary;realsalary=Wage+Subsidy-Rent-WaterFee-ElecFee;coutWageis:Wageendlendl;coutSubsidyis:Subsidyendlendl;coutRentis:Rentendlendl;coutWaterFeeis:WaterFeeendlendl;coutElecFeeis:ElecFeeendlendl;coutrealsalaryis:realsalaryendlendl;}};voidmain(){Salarya;a.setWage(2000);a.setSubsidy(300);a.setRent(500);a.setWaterFee(200);a.setElecFee(100);a.RealSalary();}实验三第三章类与对象课后习题11:设计一个工人类,它具有姓名,年龄,工作部门,工资等数据。其中工资即10题中设计的Salary类型的数据。按照第10题的形式完成工人类的程序设计,并统计工人的人数(用静态成员统计人数。)#includeiostreamusingnamespacestd;classSalary{private:doublewage,subsidy,rent,waterfee,elecfee;public:Salary(doublea,doubleb,doublec,doubled,doublee){wage=a;subsidy=b;rent=c;waterfee=d;elecfee=e;}doubleRealsalary(){doublerealsalary;realsalary=wage+subsidy-rent-waterfee-elecfee;}};classWorker{private:charname[10],dept[10];intage;doublesalary;doublewage,subsidy,rent,waterfee,elecfee,realsalary;Salarys;staticintnumber;public:Worker(char*Name,char*Dept,intA,doublea,doubleb,doublec,doubled,doublee):s(a,b,c,d,e){strcpy(name,Name);strcpy(dept,Dept);age=A;wage=a;subsidy=b;rent=c;waterfee=d;elecfee=e;realsalary=wage+subsidy-rent-waterfee-elecfee;}voiddisplay(){number++;coutnamedeptagewagesubsidyrentwaterfeeelecfeerealsalarynumber;coutendl;}};intWorker::number=0;voidmain(){cout职工姓名部门年龄基本工资岗位津贴房租水费电费实际工资人数\t;Workerp(王卫,生劳部,35,2000,300,500,100,100),q(刘畅,宣传部,28,2400,200,500,100,150),r(张明,策划部,30,2600,400,700,200,200);p.display();q.display();r.display();}实验四:第四章继承:在某高校,对员工进行工资管理普通教学人员:基本工资+课时费(课时*每课时报酬)。科研人员:基本工资+科研经费提成(每月经费*提成率)。教授:基本工资+课时费+科研经费提成+5000。专家教授:基本工资+课时费+科研经费提成+10000。#includeiostreamusingnamespacestd;classPerson{private:charname[20];intnum;public:char*getname(){returnname;}intgetnum(){returnnum;}intsetnum(intx){num=x;}Person(){};Person(char*na,intnu){strcpy(name,na);num=nu;}voidshow(){cout姓名:getname()endl;cout编号:getnum()endl;}};classPtStaff:virtualpublicPerson{private:intbsalary;inthour;intpayph;public:intsetbsalary(intx){bsalary=x;}intsethour(intx){hour=x;}intsetpayph(intx){payph=x;}intgetbsalary(){returnbsalary;}intgethour(){returnhour;}intgetpayph(){returnpayph;}intgetcpay(){returnhour*payph;}intgetrealsalary(){returnbsalary+hour*payph;}PtStaff(char*na,intnu,intbs,intho,intph):Person(na,nu){bsalary=bs;hour=ho;payph=ph;}voiddis(){cout---普通教学人员----getname()endl;show();cout基本工资:getbsalary()endl;cout课时:gethour()endl;cout每课时报酬:getpayph()endl;cout课时费:getcpay()endl;cout实际工资:getrealsalary()endlendl;}};classKyStaff:virtualpublicPerson{private:intjsalary;intoutlaypm;floattcl;public:intsetjsalary(intx){jsalary=x;}intsetoutlaypm(intx){outlaypm=x;}floatsettcl(intx){tcl=x;}intgetjsalary(){returnjsalary;}intgetoutlaypm(){returnoutlaypm;}floatgettcl(){returntcl;}floatgetjftc(){returnoutlaypm*tcl;}floatgetshijisalary(){returnjsalary+outlaypm*tcl;}KyStaff(char*na,intnu,intjs,intopm,floattc):Person(na,nu){jsalary=js;outlaypm=opm;tcl=tc;}voiddisp(){cout---科研人员----getname()endl;show();cout基本工资:getjsalary()endl;cout每月经费:getoutlaypm()endl;cout提成率:gettcl()endl;cout科研经费提成:getjftc()endl;cout实际工资:getshijisalary()endlendl;}};classProfessor:publicPtStaff,publicKyStaff{private:intjintie;public:Professor(char*na,intnu,char*nam,intnum,intbs,intho,intph,char*Nam,intNum,intjs,intopm,floattc,intjt):Person(na,nu),PtStaff(nam,num,bs,ho,ph),KyStaff(Nam,Num,js,opm,tc){jintie=jt;}voiddispl(){cout---教授----getname()endl;show();cout作为普通教学人员的工资:endl;cout基本工资:getbsalary()endl;cout课时:gethour()endl;cout每课时报酬:getpayph()endl;cout课时费:getcpay()endl;cout作为科研人员的工资:endl;cout基本工资:getjsalary()endl;