




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、 JINGCHU UNIVERSITY OF TECHNOLOGY 课程设计成果 学院:_计算机工程学院_班 级: _计算机科学与技术(一) 学生姓名: 姜桥 学 号: 2009404010121 设计地点(单位)_ A5 -101_ _设计题目:_ 电煤气管理系统_ 完成日期: 2012 年 1月 5 日 指导教师评语: _ _ _ _ 成绩(五级记分制):_ _ _ 教师签名:_ _ 目 录一课程设计目的和要求 2二课题分析 2三设计 2-31. 设计思想 2.设计分析四主程序3-19五结果显示及分析19-21六感想、收获及体会21 七参考文献22附录221 课程设计目的和要求 问题描述:
2、设计一个水电管理信息系统,能够对高校的水电费用进行管理,包括了登记费用,查询费用,以及住户信息管理等。在设计时要考虑到学生和教工在用水电时的不同,学生可以免费使用一定额度的水电,超过这个额度的随便以后必须自费使用,且自费部分水电费的价格标准要高于教工的收费标准(主要是节约资源)。基本要求:实现对用户信息的录入实现水电煤气数据的录入计算并查询用户应缴费用查询未缴纳费用名单测试数据:可选用小区物业管理部门的数据,也可采用手工输入不少于10个用户信息的数据。实现提示:用户基本信息类,教工用户信息类,学生用户信息类,收费标准类,该类存储水电煤气标准单位的收费标准,如:煤气,1.0元/立方米;不同类型人
3、员水、电、煤气信息类,这些类可以包括水表,电表,煤气表ID,抄表时间,上次抄表时间,本次抄表时间,上次抄表度数,本次抄表度数,本次使用度数,费用,是否缴费标记等信息。在实现的时候考虑继承和多态技术的合理使用。二课题分析: 本程序是一个水电气管理信息系统,能够对高校的水电气费用进行管理,包括了成员基本信息,如学号、编号、姓名、成员水电气的用量;程序的用途包括缴纳水电气费、查询一个同学水电气费用量"、查看所有同学的缴费情况、增加学生信息、删除学生信息、退出系统等。在设计时也考虑到学生和教师在用水电气时的不同,学生可以免费使用一定额度的水电气,超过这个额度的以后必须付费,且付费部分水电气费
4、的价格要高于教工的收费标准,该措施的实行是为了鼓励同学们节约用水,以免造成不必要的资源浪费。该软件主要是为了学校的管理人员提供便捷,以更快的完成水电气费用的收缴。3 设计1.设计思想:设计面向对象的程序设计语言,首先考虑的肯定是要设计类。程序设计了四个类,两个是学生类,两个是教师类。在主函数中用动态数组,机动的分配类存,以至于不造成类存的浪费。在本程序中涉及用户的选择,用户要根据自己的实际需要选择不同的功能,由于选择的多样性,程序中必须要有switch结构控制各个功能的选择,如果需要多次进行操作,则要在switch结构的外部,通过循环来实现。首先该程序的第一目的是要读附录里的内容,然后再根据用
5、户的选项来实现各种不同的功能,当正确按照要求就可进行更进一步进行操作,直到你达到自己的目的为止。本程序通过调用不同的函数来实现不同的功能,通过用户自己的选择可以自己进行操作,在主函数中申明的函数分别起到不同的作用,在本程序中所有的子函数都是在主函数外实现的。在子函数的函数体中为了使程序的功能和细节更加的完善,在子函数中设置菜单,这样不仅使得程序更加完善还有利于用户的操作。使得程序更加简洁明了。2设计分析:在这个电煤气管理系统中,共用到了四个类,一个是stut类,它起的作用是把水电煤气的用量和每个人的缴费信息结合在一起,还有赋值运算符重载、插入运算符重载,最重要的就是那些对象都有共同的属性,通过
6、这个类把学号、姓名、水用量、电用量、气用量集中到一起,所以才能设计一个类;另一个类就是arrayofStu 学生类计算类,这个类的作用主要就是一些功能的实现,有主菜单、交费菜单、交费功能和、查询菜单、查询功能、增加功能、删除菜单、删除功能、查看功能。同样定义一个teacher它起的作用是把水电煤气的用量和每个人的缴费信息结合在一起,还有赋值运算符重载、插入运算符重载,最重要的就是那些对象都有共同的属性,通过这个类把姓名、水用量、电用量、气用量集中到一起,所以才能设计一个类;其另一个类就是arrayofTeacher老师类数组计算,这个类的作用主要就是一些功能的实现,有主菜单、交费菜单、交费功能
7、和、查询菜单、查询功能、增加功能、删除菜单、删除功能、查看功能四主程序#include "iostream"#include"string"#include"fstream"#include"iomanip"using namespace std;int count1=0,count11=0; /学生总数和交钱的人数int count2=0,count22=0;class Stupublic:Stu(double xwater=0,double xpower=0,double xgas=0,string xnum=
8、"a",string xna="a"); /学生类构造函数 void operator =(Stu S); /赋值运算符重载 friend ostream &operator <<(ostream & a,Stu &S) /插入运算符重载a<<setw(8)<<left<<S.number; a<<setw(8)<<left<<S.name; a<<setw(8)<<left<<S.water; a<<
9、;setw(8)<<left<<S.power; a<<setw(8)<<left<<S.gas; a<<setw(8)<<left<<S.SGetW(); a<<setw(8)<<left<<S.SGetC(); a<<setw(8)<<left<<S.SGetG(); a<<setw(8)<<left<<S.Stotal(); if(S.flag) a<<"已交&qu
10、ot; else a<<"未交" cout<<endl; return a; double SGetW(); /计算水费 double SGetC(); /计算电费 double SGetG(); /计算煤气费 double Stotal(); /计算总费用 double water,power,gas,water_rate,circuit,gas_rate,total; int flag; string number,name;Stu:Stu(double xwater,double xpower,double xgas,string xnum,s
11、tring xna) /学生类构造函数 water=xwater; power=xpower; gas=xgas; number=xnum; name=xna; flag=0;void Stu:operator =(Stu S) /赋值运算符重载 name=S.name; number=S.number; water=S.water; power=S.power; gas=S.gas;double Stu:SGetW( ) /计算水费if(water<10) water_rate=0;else water_rate=4.2*(water-10); return water_rate;do
12、uble Stu:SGetC() /计算电费if(power<10) circuit=0;else circuit=0.6*(power-10); return circuit; double Stu:SGetG() /计算煤气费if(gas<10) gas_rate=0;else gas_rate=2.3*(gas-10); return gas_rate;double Stu:Stotal() /计算总的钱 total=SGetG()+SGetW()+SGetC();return total;class arrayofStu /学生类计算public: arrayofStu(i
13、nt sz=1) size=sz; student=new Stusize; /构造函数 arrayofStu() delete student; void xuesheng(); /学生用户主菜单 void jiaofei(); /学生交费菜单 void regist(); /登记学生 void amend( ); /修改用户菜单 void add( ); /增加用户 void delet(); / 删除用户菜单 void nad(); /姓名删除 void numd(); /学号删除 void check( ); /查询菜单 void nacheck(); /姓名查询 void numch
14、eck(); /学号查询 void naj(); /输入姓名交费 void numj(); /输入学号交费 void display(); /查看交费情况 void save(); private: int size; Stu *student;void arrayofStu:regist() /学生用户注册 int i=0; ifstream f("Stu.txt");while(f.good() / !f.eof()f>>studenti.number;f>>;f>>studenti.water;f>&
15、gt;studenti.power;f>>studenti.gas;i+;f.close();count1=i;cout<<"tt 注册成功!"<<endl;void arrayofStu:naj( ) /输入姓名交费 char ch; double money,money2; cout<<"ttt欢迎使用姓名交费功能"<<endl; string na; cout<<"请输入学生姓名:"<<endl; cin>>na; int fl=0;
16、for(int i=0;i<count1;i+) if(na=) fl=1; if(studenti.flag) cout<<"该学生已缴纳过费用"<<endl; else cout<<"你应该交"<<studenti.Stotal()<<"钱"<<endl; cout<<"确定是否真的现在交费 (Y/N)"<<endl; cin>>ch; if(ch='Y'|
17、ch='y') studenti.flag=1; cout<<"你实际交的钱是:"<<endl; cin>>money; if(money>studenti.Stotal() cout<<"找零"<<money-studenti.Stotal()<<"钱"<<endl; if(studenti.Stotal()>money) cout<<"交的钱不够,还应交"<<studenti.
18、Stotal()-money<<"钱"<<endl; cout<<"补交:" cin>>money2; cout<<"交费成功"<<endl; count11+; xuesheng(); else xuesheng(); if(!fl) cout<<"没有这个学生"<<endl; void arrayofStu:numj( ) /输入学号交费 cout<<"ttt欢迎使用学号交费功能"&l
19、t;<endl; string num;double money,money2;char ch; cout<<"请输入学生学号:"<<endl; cin>>num; int fl=0;for(int i=0;i<count1;i+) if(num=studenti.number) if(studenti.flag) fl=1; cout<<"该学生已缴纳过费用"<<endl; else cout<<"你应该交"<<studenti.Stot
20、al()<<"钱"<<endl; cout<<"确定是否真的现在交费 (Y/N)"<<endl; cin>>ch; if(ch='Y'|ch='y') studenti.flag=1; cout<<"你实际交的钱是:"<<endl; cin>>money; if(money>studenti.Stotal() cout<<"找零"<<money-student
21、i.Stotal()<<"钱"<<endl; if(studenti.Stotal()>money) cout<<"交的钱不够,还应交"<<studenti.Stotal()-money<<"钱"<<endl; cout<<"补交:" cin>>money2; cout<<"交费成功"<<endl; count11+; xuesheng(); else xuesheng(
22、); if(!fl) cout<<"没有这个学生"<<endl; void arrayofStu:add() /增加学生cout<<"ttt欢迎使用增加学生功能"<<endl;cout<<"请输入学生的姓名:"<<endl;cin>>;cout<<"请输入学生的学号:"<<endl;cin>>studentcount1.number;cout<<&q
23、uot;请输入学生的用水量:"<<endl;cin>>studentcount1.water;cout<<"请输入学生的用电量:"<<endl;cin>>studentcount1.power;cout<<"请输入学生的用煤气量:"<<endl;cin>>studentcount1.gas;count1+;cout<<"ttt学生信息已被成功的增加!"<<endl;void arrayofStu:nad(
24、) /按姓名删除 cout<<"ttt欢迎使用姓名删除学生功能"<<endl;/*cout<<student0;cout<<endl<<;*/int fl=0;int i,j; string na;cout<<"请输入要删除学生的姓名"<<endl;cin>>na;for(i=0;i<count1;i+)if(na=) fl=1;break;if(fl) for(j=i;j<count1-1;j+
25、) studentj=studentj+1;count1-;cout<<"你已成功删除学生信息"<<endl;else cout<<"没有这个学生"<<endl;void arrayofStu:display() int i;if(count11=0) cout<<"暂时还无学生交费"<<endl;elsecout<<"已交费人员信息"<<endl;cout<<"学号 "<<&
26、quot;姓名 "<<" 用水量 "<<"用电量 "<<"用煤气量 "<<"水费 "<<"电费 "<<"煤气费 "<<" 总额 "<<" 是否交费"<<endl;for( i=0;i<count1;i+) if(studenti.flag) cout<<studenti; if(count11=coun
27、t1) cout<<"所有学生均以交费"<<endl;else cout<<"未交费人员信息"<<endl; cout<<"学号 "<<"姓名 "<<" 用水量 "<<"用电量 "<<"用煤气量 "<<"水费 "<<"电费 "<<"煤气费 "<<
28、;" 总额 "<<" 是否交费"<<endl; for(i=0;i<count1;i+) if(!studenti.flag) cout<<studenti;void arrayofStu:numd( ) /按学号删除cout<<"ttt欢迎使用学号删除学生功能"<<endl;int fl=0;int i,j;string num;cout<<"请输入要删除学生的学号"<<endl;cin>>num;for(i=0
29、;i<count1;i+)if(num=studenti.number) fl=1;break;if(fl)for(j=i;j<count1-1;j+) studentj=studentj+1;count1-;cout<<"你已成功删除学生信息"<<endl;else cout<<"没有这个学生"<<endl;void arrayofStu:nacheck( ) /姓名查询 cout<<"ttt欢迎使用姓名查询学生功能"<<endl;int i,fl=
30、0; string na; cout<<"请输入要查找的姓名"<<endl; cin>>na;for(i=0;i<count1;i+) if(na=) fl=1;break;if(fl) cout<<"学号 "<<"姓名 "<<" 用水量 "<<"用电量 "<<"用煤气量 "<<"水费 "<<"电
31、费 "<<"煤气费 "<<" 总额 "<<" 是否交费"<<endl; cout<<studenti<<endl;else cout<<"没有这个学生"<<endl;void arrayofStu:numcheck() /学号查询 cout<<"ttt欢迎使用学号查询学生功能"<<endl; int i,fl=0;string num;cout<<&quo
32、t;请输入要查找的学号"<<endl;cin>>num;for(i=0;i<count1;i+) if(num=studenti.number) fl=1;break;if(fl)cout<<"学号 "<<"姓名 "<<" 用水量 "<<"用电量 "<<"用煤气量 "<<"水费 "<<"电费 "<<"煤气费 &q
33、uot;<<" 总额 "<<" 是否交费"<<endl; cout<<studenti<<endl;else cout<<"没有这个学生"<<endl;void arrayofStu:save() ofstream f("Stu2.txt"); f<<"学号 "<<"姓名 "<<" 用水量 "<<"用电量 "
34、;<<"用煤气量 "<<"水费 "<<"电费 "<<"煤气费 "<<" 总额 "<<" 是否交费"<<endl;for(int i=0;i<count1;i+)f<<studenti<<endl;f.close();cout<<"恭喜你,文件已成功保存"<<endl;void arrayofStu:delet() /删除
35、学生菜单 int choice; cout<<"tttt*"<<endl; cout<<"tttt 删除信息"<<endl; cout<<"tttt 1,按学号删除"<<endl; cout<<"tttt 2,按姓名删除"<<endl; cout<<"tttt 3,返回主菜单"<<endl; cout<<"tttt 0,返回上一层"<<
36、;endl; cout<<"tttt*"<<endl; while(1) cout<<"请输入你的选择"<<endl; cin>>choice; switch(choice) case 1: numd(); break; /学号删除 case 2: nad(); break; /姓名删除 case 3: xuesheng(); break; /返回学生管理主菜单 case 0: amend(); break; /返回上一层 if(choice=0) break; void arrayofStu:
37、jiaofei() /学生缴费菜单int choice;cout<<"tttt*"<<endl;cout<<"tttt*-学生缴费-*"<<endl;cout<<"tttt*1,输入学号交费*"<<endl;cout<<"tttt*2,输入姓名交费*"<<endl; cout<<"tttt*0, 返回上一层 *"<<endl; cout<<"tttt*&q
38、uot;<<endl; while(1) cout<<"请输入你的选择"<<endl; cin>>choice;switch(choice) case 1: numj(); break; /输入学号计费 case 2: naj(); break; /输入姓名计费 case 0: xuesheng(); break; /返回上一层 if(choice=0) break;void arrayofStu:xuesheng() /学生用户主菜单int choice;cout<<"tttt欢迎使用学生用户管理系统&
39、quot;<<endl<<endl;cout<<"*"<<endl; cout<<"tttt*-1,注册学生-*"<<endl;cout<<"tttt*-2,修改用户-*"<<endl;cout<<"tttt*-3,缴纳费用-*"<<endl;cout<<"tttt*-4,查询费用-*"<<endl;cout<<"tttt*-5,查
40、看交费情况-*"<<endl;cout<<"tttt*-6,保存信息到文件-*"<<endl;cout<<"tttt*-0,返回上一层-*"<<endl;cout<<"*"<<endl;cout<<"友情提示:第一次使用时,要进行注册!"<<endl<<endl;for(;)cout<<"请输入您的选择"<<endl;cin>>ch
41、oice;switch(choice) case 1: regist(); break; /注册 case 2: amend(); break; /修改 case 3: jiaofei(); break; /缴纳费用 case 4: check(); break; case 5: display(); break; case 6: save(); break; case 0: break; if(choice=0) break; void arrayofStu:amend() /修改用户菜单int choice;cout<<"tttt修改学生信息"<<
42、;endl<<endl;cout<<"tttt1,增加学生 "<<endl;cout<<"tttt2,删除学生 "<<endl; cout<<"tttt0,回上一层 "<<endl; while(1) cout<<"请输入你的选择"<<endl; cin>>choice; switch(choice)case 1: add(); break; case 2: delet(); break; cas
43、e 0: xuesheng(); break; if(choice=0)break;void arrayofStu:check() /查询菜单int choice;cout<<"tt 查询学生信息"<<endl<<endl;cout<<" 1,按姓名查找 "<<endl;cout<<" 2,按学号查找 "<<endl;cout<<" 0,返回上一层 "<<endl;cout<<"=&qu
44、ot;<<endl;while(1)cout<<"请输入您的选择"<<endl;cin>>choice;switch(choice)case 1: nacheck(); break; /输入姓名查找case 2: numcheck(); break; /输入学号查找case 0:xuesheng(); break;/如果是break时分析 if(choice=0)break;class Teacher /教师 public: Teacher( double xwater=0,double xpower=0,double xga
45、s=0,string xname="a") water=xwater;power=xpower;gas=xgas;name=xname;flag=0; void operator =(Teacher S); /赋值运算符重载 friend ostream &operator <<(ostream & a,Teacher &S) /插入运算符重载 a<<setw(6)<<left<<S.name; a<<setw(6)<<left<<S.water; a<<
46、setw(10)<<S.power; a<<setw(10)<<S.gas; a<<setw(10)<<S.TGetW(); a<<setw(10)<<S.TGetC(); a<<setw(10)<<S.TGetG(); a<<setw(10)<<S.Ttotal(); if(S.flag) a<<"已交" else a<<"未交" cout<<endl; return a; double
47、 TGetW(); /水费计算 double TGetC(); /电费计算 double TGetG(); /煤气费计算 double Ttotal(); /计算总的钱 string name; double water,power,gas,water_rate,circuit,gas_rate,total; int flag;void Teacher:operator =(Teacher S) /赋值运算符重载name=S.name;water=S.water;power=S.power;gas=S.gas;double Teacher:TGetW() /计算水费 water_rate=3.
48、7*water; return water_rate; double Teacher:TGetC() /计算电费 circuit=0.45*power; return circuit; double Teacher:TGetG() /计算煤气费gas_rate=1.9*gas;return gas_rate;double Teacher:Ttotal() /计算应该付的的钱total=TGetW()+TGetC()+TGetG();return total;class arrayofTeacher /老师类数组计算 public: arrayofTeacher( int sz=1) size=
49、sz;teacher=new Teachersize; arrayofTeacher() delete teacher ; void regist(); /注册教工 void jiaogong(); /教工主菜单 void amend( ); /修改用户菜单 void add(); /增加用户 void delet(); / 删除用户 void check(); /查询是否交费 void jiaofei(); /交水电煤气费 / void display(); /展示所有的用户 void display(); /查看交费情况 void save(); private: int size; Te
50、acher *teacher; ;void arrayofTeacher:regist() /教工用户注册 int i=0; ifstream f("Teacher.txt");while(f.good()f>>;f>>teacheri.water;f>>teacheri.power;f>>teacheri.gas;i+;f.close();count2=i;cout<<"tt 注册成功,祝你使用愉快"<<endl;void arrayofTeacher:j
51、iaofei() /用户交费 char ch;string na;cout<<"ttt欢迎使用交费功能"<<endl;cout<<"请输入姓名:"<<endl;cin>>na;int fl=0;double money,money2;for(int i=0;i<count2;i+)if(na=) fl=1; if(teacheri.flag) cout<<"该教工已缴纳过费用"<<endl; break; else co
52、ut<<"你应该交"<<teacheri.Ttotal()<<"钱"<<endl; cout<<"确定是否真的现在交费 (Y/N)"<<endl; cin>>ch; if(ch='Y'|ch='y') teacheri.flag=1; cout<<"你实际交的钱是:"<<endl; cin>>money; if(money>teacheri.Ttotal()
53、cout<<"找零"<<money-teacheri.Ttotal()<<"钱"<<endl; if(teacheri.Ttotal()>money) cout<<"交的钱不够,还应交"<<teacheri.Ttotal()-money<<"钱"<<endl; cout<<"补交:" cin>>money2; cout<<"交费成功"<
54、;<endl;count22+; jiaogong(); else jiaogong(); if(!fl) cout<<"没有这个教工"<<endl;void arrayofTeacher:add() /增加教工cout<<"ttt欢迎使用增加教工功能"<<endl;cout<<"请输入教工的姓名"<<endl;cin>>;cout<<"请输入教工的用水量"<<end
55、l;cin>>teachercount2.water;cout<<"请输入教工的用电量"<<endl;cin>>teachercount2.power;cout<<"请输入教工的用煤气量"<<endl;cin>>teachercount2.gas;count2+;cout<<"ttt教工已被成功增加!"<<endl;void arrayofTeacher:delet( ) /删除教工cout<<"ttt欢迎
56、使用删除教工功能"<<endl;int fl=0;int i,j;string name;cout<<"请输入要删除教工的姓名"<<endl;cin>>name;for(i=0;i<count2;i+)if(name=) fl=1;break;if(fl)for(j=i;j<count2-1;j+) /不能写成for(j=i;j<size;j+) teacherj=teacherj+1;count2-;cout<<"你已成功删除教工信息"&l
57、t;<endl; Else cout<<"没有这个教工"<<endl;void arrayofTeacher:check( ) /查找交费情况 cout<<"ttt欢迎使用查费功能"<<endl;string na;int i=0,fl=0; cout<<"请你输入姓名"<<endl;cin>>na;for(i=0;i<count2;i+) if(na=) fl=1;break;if(fl) cout<<
58、;"姓名 "<<"用水量 "<<"用电量 "<<"用煤气量 "<<"水费 "<<"电费 "<<"煤气费 "<<" 总额 "<<" 是否交费"<<endl; cout<<teacheri<<endl;else cout<<"没有这个教工"<<endl; void arrayofTeacher:display() /查看交费情况 int i; if(count22=0)cout<<"暂时还无教工交钱"<<endl; elsecout<<"已交费人员信息"<<endl; cout<&l
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 中俄外贸合同范例
- 2025车辆抵押担保合同样本
- 公司承担债务合同范例
- 便利商店转让合同范例
- 2025汽车租赁合同简单模板汽车租赁合同书样本
- 2025年健康教育与健康促进考试试卷及答案咨询
- 个人签定劳动合同样本
- 2014设备保养合同范例
- 2025年新能源技术与应用发展趋势分析试题及答案
- 个人车位购买合同范例
- 高校人才引进机制研究
- 【高中物理竞赛专题大全】竞赛专题1力学50题竞赛真题强化训练解析版
- 《2023中国会议统计分析报告》
- 山东省淄博市光被中学高三物理下学期期末试卷含解析
- 上消化道出血病人的护理
- 2020教学能力大赛国赛一等奖实施报告汇报PPT-国一
- 信访事项复查申请书
- 2023学年完整公开课版《老师领进门》
- 《伊利乳业集团企业内部审计存在的问题及优化对策分析案例(论文)10000字》
- 2023年副主任医师(副高)-急诊医学(副高)考试历年高频考点真题附带含答案
- 2023年全国职业院校技能大赛竞赛英语口语项目方案申报书
评论
0/150
提交评论