1、电煤气管理系统c+源代码#include iostream#include string#include cstdlib#include iomanip#include fstreamusing namespace std;int ns,nt; class Feebz /学生的信息类public:Feebz(string Num=0904032011,string Name=任家双,double water=1,double power=0,double gas=10); / 构造函数 friend ostream &operator (ostream &out,Feebz &r) /运算符重
2、载 outsetw(12)leftr.number; outsetw(8)leftr.name; outsetw(8)leftr.water; outsetw(8)leftr.power; outsetw(8)leftr.gas; outsetw(8)leftr.GetW(); outsetw(8)leftr.GetP(); outsetw(8)leftr.GetG(); outsetw(8)leftr.GetTotal(); if(r.flag) out已交; else out未交; return out; void operator =(Feebz r); /运算符重载 double Ge
3、tW(); /计算学生水费 double GetP(); /计算学生电费 double GetG(); /计算学生气费 double GetTotal() return GetW()+GetP()+GetG(); /计算学生总费用 string number,name;int flag;double water,power,gas,Waterprice,Powerprice,Gasprice; ; Feebz:Feebz(string Num,string Name,double Water,double Power,double Gas) /构造函数 number=Num; name=Nam
4、e; water=Water; power=Power; gas=Gas; flag=0; void Feebz:operator =(Feebz r) /赋值运算符重载 name=r.name; number=r.number; water=r.water; power=r.power; gas=r.gas; double Feebz:GetW() /计算学生水费 if(water=6) Waterprice=0; else Waterprice=0.6*(water-6);return Waterprice; double Feebz:GetP() /计算学生电费 if(power=6)
5、Powerprice=0; else Powerprice=0.6*(power-6); return Powerprice; double Feebz:GetG() /计算学生气费if(gas=6) Powerprice=0; else Powerprice=0.6*(gas-6); return Powerprice; class StuMan /学生管理类public: StuMan(int sz=50) size=sz; St=new Feebzsize; /构造函数 StuMan() delete St; / 析构函数void MainMenu(); / 主菜单void FeeMen
6、u(); /学生交费菜单 void NumFee(); / 输入学号交费 void NameFee(); / 输入姓名交费 void CheckMenu(); / 学生查询菜单 void NumCheck(); / 输入学号查询 void NameCheck(); /输入姓名查询 void Add(); / 增加学生功能 void DeleteMenu(); / 学生删除菜单 void NumDelete(); / 输入学号删除 void NameDelete(); / 输入姓名删除 void Regist(); void Chakan(); / 学生查看作用private:int size;
7、Feebz *St; ; void StuMan:MainMenu() / 主菜单 system(cls); int choice; cout*endl; cout 欢迎使用学生水电气费管理系统endl; cout 1.缴纳水电气费endl; cout 2.查询一个同学水电气费用量endl; cout 3.查看所有同学的缴费情况endl; cout 4.增加学生信息endl; cout 5.删除学生信息endl; cout 6.退出系统endl; cout*endl; while(1) coutchoice; switch(choice) case 1:FeeMenu(); break; ca
8、se 2:CheckMenu(); break; case 3:Chakan(); break; case 4:Add(); break; case 5:DeleteMenu(); break; default: break; if(choice=6) break; void StuMan:Regist() int i=0; ifstream tfile(student.txt); while(tfile.good() tfileSti.number; tfileSti.name; tfileSti.water; tfileSti.power; tfileSti.gas; i+; tfile.
9、close(); ns=i; void StuMan:FeeMenu() /学生交费菜单 system(cls); int choice; cout *endl; cout 学 生 交 费 菜 单endl; cout 1.按照学号交费endl; cout 2.按照姓名交费endl; cout 3.返回主菜单endl; cout 4.退出系统endl; cout *endl; while(1) coutchoice; switch(choice) case 1:NumFee(); break; case 2:NameFee(); break; case 3:system(cls); MainMe
10、nu(); break; default:exit(1); if(choice=3) break; void StuMan:NumFee() /输入学号交费 string number; float money; int flag=0,flag1=0; cout 欢迎使用交费功能endl; coutnumber; for(int i=0;ins;i+) if(number=Sti.number) flag1=1; cout该同学应该交费共Sti.GetTotal()元endl; coutmoney; if(moneySti.GetTotal() cout该同学需再补交Sti.GetTotal(
11、)-money元endl; Sti.flag=0; MainMenu(); else cout该同学交费成功,且找零钱为money-Sti.GetTotal()元endl; Sti.flag=1; MainMenu(); break; if(!flag1) system(cls);cout该学生的学号输入错误,请重新使用该功能!endl;NumFee(); void StuMan:NameFee() /输入姓名交费 string name; float money; int flag=0,flag1=0; cout 欢迎使用交费功能endl; coutname; for(int i=0;ins
12、;i+) if(name=Sti.name) flag1=1; cout该同学应该交费共Sti.GetTotal()元endl; coutmoney; if(moneySti.GetTotal() cout该同学需再补交Sti.GetTotal()-money元endl; Sti.flag=0; MainMenu(); else cout该同学交费成功,且找零钱为money-Sti.GetTotal()元endl; Sti.flag=1; MainMenu(); break; if(!flag1) system(cls); cout该学生的姓名输入错误,请重新使用该功能!endl; NameFee(); void StuMan:CheckMenu() /学生查询菜单 system(cls); int choice; cout *endl; cout 学 生 查 询 菜 单endl; cout 1.按照学号查询endl; cout 2.按照姓名查询endl; cout 3.返回主菜单endl; cout 4.退出系统endl; co
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1