ImageVerifierCode 换一换
格式:DOCX , 页数:33 ,大小:21.06KB ,
资源ID:12709075      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bingdoc.com/d-12709075.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(宿舍管理系统代码实现.docx)为本站会员(b****8)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

宿舍管理系统代码实现.docx

1、宿舍管理系统代码实现VC+6.0实现的代码由于数据库暂时没学会,利用了文本文件进行保存 修改 用户数据#include iostream#includestring#includefstream#includeiomanipusing 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=a,string xna=a); /学生类构造函数 void

2、operator =(Stu S); /赋值运算符重载 friend ostream &operator (ostream & a,Stu &S) /插入运算符重载 asetw(8)leftS.number; asetw(8)leftS.name;/输出时左对齐8位 asetw(8)leftS.water; asetw(8)leftS.power; asetw(8)leftS.gas; asetw(8)leftS.SGetW(); asetw(8)leftS.SGetC(); asetw(8)leftS.SGetG(); asetw(8)leftS.Stotal(); if(S.flag!=0

3、) a已交; else a未交; coutendl; 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,string xna) /学生类构造函数 wat

4、er=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(water10) water_rate=0;else water_rate=4.2*(water-10); return water_rate;double Stu:SGetC() /计算电费if(pow

5、er10) circuit=0;else circuit=0.6*(power-10); return circuit; double Stu:SGetG() /计算煤气费if(gasstudenti.number;fstudenti.name;fstudenti.water;fstudenti.power;fstudenti.gas;i+;f.close();count1=i;couttt 注册成功!endl; void arrayofStu:naj( ) /输入姓名交费 char ch;double money,money2; coutttt欢迎使用姓名交费功能endl; string n

6、a;cout请输入学生姓名:na;int fl=0; for(int i=0;icount1;i+) if(na=studenti.name) fl=1; if(studenti.flag) cout该学生已缴纳过费用endl; else cout你应该交studenti.Stotal()钱endl; cout确定是否真的现在交费 (Y/N)ch; if(ch=Y|ch=y) studenti.flag=1; cout你实际交的钱是:money; if(moneystudenti.Stotal() cout找零money-studenti.Stotal()钱money) cout交的钱不够,还

7、应交studenti.Stotal()-money钱endl; coutmoney2; cout交费成功endl;count11+; xuesheng(); else xuesheng(); if(!fl) cout没有这个学生endl; void arrayofStu:numj( ) /输入学号交费 coutttt欢迎使用学号交费功能endl; string num;double money,money2;char ch;cout请输入学生学号:num;int fl=0; for(int i=0;icount1;i+) if(num=studenti.number) if(studenti.

8、flag) fl=1; cout该学生已缴纳过费用endl; else cout你应该交studenti.Stotal()钱endl; cout确定是否真的现在交费 (Y/N)ch; if(ch=Y|ch=y) studenti.flag=1; cout你实际交的钱是:money; if(moneystudenti.Stotal() cout找零money-studenti.Stotal()钱money) cout交的钱不够,还应交studenti.Stotal()-money钱endl; coutmoney2; cout交费成功endl;count11+; xuesheng(); else

9、xuesheng(); if(!fl) cout没有这个学生endl; void arrayofStu:add() /增加学生coutttt欢迎使用增加学生功能endl;cout请输入学生的姓名:studentcount1.name;cout请输入学生的学号:studentcount1.number;cout请输入学生的用水量:studentcount1.water;cout请输入学生的用电量:studentcount1.power;cout请输入学生的用煤气量:studentcount1.gas;count1+;coutttt学生信息已被成功的增加!endl;void arrayofStu:

10、nad( ) /按姓名删除 coutttt欢迎使用姓名删除学生功能endl; /*coutstudent0; coutendlstudent0.name;*/int fl=0; int i,j; string na;cout请输入要删除学生的姓名na;for(i=0;icount1;i+)if(na=studenti.name) fl=1;break;if(fl)for(j=i;jcount1-1;j+) studentj=studentj+1;count1-;cout你已成功删除学生信息endl;else cout没有这个学生endl;void arrayofStu:display() in

11、t i; if(count11=0) cout暂时还无学生交费endl; elsecout已交费人员信息endl; cout学号 姓名 用水量 用电量 用煤气量 水费 电费 煤气费 总额 是否交费endl; for( i=0;icount1;i+) if(studenti.flag) coutstudenti; if(count11=count1) cout所有学生均以交费endl; else cout未交费人员信息endl; cout学号 姓名 用水量 用电量 用煤气量 水费 电费 煤气费 总额 是否交费endl; for(i=0;icount1;i+) if(!studenti.flag)

12、 coutstudenti;void arrayofStu:numd( ) /按学号删除coutttt欢迎使用学号删除学生功能endl;int fl=0; int i,j;string num;cout请输入要删除学生的学号num;for(i=0;icount1;i+)if(num=studenti.number) fl=1;break;if(fl)for(j=i;jcount1-1;j+) studentj=studentj+1;count1-;cout你已成功删除学生信息endl;else cout没有这个学生endl;void arrayofStu:nacheck( ) /姓名查询 co

13、utttt欢迎使用姓名查询学生功能endl; int i,fl=0;string na;cout请输入要查找的姓名na;for(i=0;icount1;i+) if(na=studenti.name) fl=1;break;if(fl) cout学号 姓名 用水量 用电量 用煤气量 水费 电费 煤气费 总额 是否交费endl; coutstudentiendl;else cout没有这个学生endl;void arrayofStu:numcheck() /学号查询 coutttt欢迎使用学号查询学生功能endl; int i,fl=0;string num;cout请输入要查找的学号num;f

14、or(i=0;icount1;i+) if(num=studenti.number) fl=1;break;if(fl)cout学号 姓名 用水量 用电量 用煤气量 水费 电费 煤气费 总额 是否交费endl; coutstudentiendl;else cout没有这个学生endl;void arrayofStu:save() ofstream f(Stu2.txt); f学号 姓名 用水量 用电量 用煤气量 水费 电费 煤气费 总额 是否交费endl; for(int i=0;icount1;i+) fstudentiendl; f.close(); /cout恭喜你,文件已成功保存end

15、l; void arrayofStu:delet() /删除学生菜单int choice; couttttt*endl; couttttt 删除信息endl; couttttt 1,按学号删除endl; couttttt 2,按姓名删除endl; couttttt 3,返回主菜单endl; couttttt 0,返回上一层endl; couttttt*endl; while(1) cout请输入你的选择choice; switch(choice) case 1: numd(); break; /学号删除 case 2: nad(); break; /姓名删除 case 3: xuesheng(

16、); break; /返回学生管理主菜单 case 0: amend(); break; /返回上一层 if(choice=0) break; void arrayofStu:jiaofei() /学生缴费菜单 int choice; couttttt*endl; couttttt*-学生缴费-*endl; couttttt*1,输入学号交费*endl; couttttt*2,输入姓名交费*endl; couttttt*0, 返回上一层 *endl; couttttt*endl; while(1) cout请输入你的选择choice; switch(choice) case 1: numj()

17、; break; /输入学号计费 case 2: naj(); break; /输入姓名计费 case 0:xuesheng(); break; /返回上一层 if(choice=0) break; void arrayofStu:xuesheng() /学生用户主菜单 int choice; couttttt欢迎使用学生用户管理系统endlendl; cout*endl; couttttt*-1,注册学生-*endl; couttttt*-2,修改用户-*endl; couttttt*-3,缴纳费用-*endl; couttttt*-4,查询费用-*endl; couttttt*-5,查看交

18、费情况-*endl; couttttt*-6,保存信息到文件-*endl; couttttt*-0,返回上一层-*endl; cout*endl; cout友情提示:第一次使用时,要进行注册,否则,后果自负!endlendl; for(;) cout请输入您的选择choice; switch(choice) case 1: regist(); break; /注册 case 2: amend(); break; /修改 case 3: jiaofei(); break; /缴纳费用 case 4: check(); break; case 5: display(); break; case 6

19、: save(); break; case 0: break; if(choice=0) break; void arrayofStu:amend() /修改用户菜单 int choice; couttttt修改学生信息endlendl; couttttt1,增加学生 endl; couttttt2,删除学生 endl; couttttt0,回上一层 endl; while(1) cout请输入你的选择choice; switch(choice) case 1: add(); break; case 2: delet(); break; case 0: xuesheng(); break; i

20、f(choice=0) break; void arrayofStu:check() /查询菜单 int choice; couttt 查询学生信息endlendl; cout 1,按姓名查找 endl; cout 2,按学号查找 endl; cout 0,返回上一层 endl; cout=endl; while(1) cout请输入您的选择choice; switch(choice) case 1: nacheck(); break; /输入姓名查找 case 2: numcheck(); break; /输入学号查找 case 0:xuesheng(); break;/如果是break时分析 if(choice=0)break; /*

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2