




免费预览已结束,剩余16页可下载查看
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
三峡大学理学院2010级电子信息科学与技术专业高级语言程序设计课程设计说明书设计题目: 客房管理系统班级: 学号: 姓名: 完成日期: 2011-11-23目录一、 设计任务(2)二、 需求分析(2)三、 系统模块图(2)四、 模块说明(3)五、 用户说明(18)六、 测试结果 (18)七、 设计小结 (19)八、 参考目录 (19)一、设计任务:客房管理系统实现用户登记功能,要提供结构体的输入操作,实现统计功能,要提供相应的统计操作,实现查询功能,要提供查找操作,实现修改功能,要提供修改操作;另外还有提供键盘式菜单实现功能选择。二、需求分析:1. 总体分析:整个客房管理系统被设计为用户登记模块,统计模块,查询模块,和修改模块。2. 详细分析:(1) 用户登记模块 提示用户输入自身信息以及客房信息,把数据存入room数组中。(2) 统计模块18设置计数器,顺序遍历room数组来实现,实现对房客数、某一天的房客数的统计。(3) 查询模块 通过基本查找算法查找room数组,可以按房间号、价格、房间标记、用户姓名、居民身份证查询。(4) 修改模块 采用基本查找算法在数组找到要修改的数据。三、系统模块图根据需求分析,可以对这个系统的设计分为以下几个模块:客户信息管理系统数据输入数据统计数据查询数据修改数据删除四、模块说明:一个较大的c语言程序不外乎由多个函数组成,本程序也并不例外。现就本程序中涉及的各个函数的代码和功能分别进行说明。1、 主函数部分:程序:void main() /*主函数*/ int n,w; menu(); do printf(ttplease choice you number(1-5); scanf(%d,&n); if(n5) w=1,getchar(); else w=0; while(w=1); switch(n) case 1:regist();break; case 2:stati();break; case 3:search();break; case 4:modify();break; case 5:exit(0); void menu () /*菜单函数*/ printf(ttt*客房管理系统*n); puts(nttt (1).登记 n); puts(ttt (2).统计 n); puts(ttt (3).查询 n); puts(ttt (4).修改 n); puts(ttt (5).退出 n); puts(nt*n); void return_confirm(void) printf(n按任意键返回n); getchar(); #include stdio.h #include string.h /在使用中要用到的字符串都包含在本文件中#include stdlib.h #include math.h #define num 50 struct client char name20; int sex; /famale 0,male 1; int age; char id_card20; /*居民身份证*/ int year; int month; int date; /*住店时间*/; struct hotel char room_id10; /*房间号*/ char tel10; int price; /*住房单价*/ int sign; struct client client_list; /*实现两个结构体的嵌套*/roomnum; 注:menu函数能提供菜单方式选择功能,可以根据用户需要进入到所想要的操作模块中,此外把menu函数独立出来,可以方便随时对它进行调用,容易返回到系统界面。并用结构体来存放客户信息。2、各功能模块函数部分:(1)输入模块:需求分析 对信息进行输入程序:void regist() /*登记函数*/ void printf_one(int i); void save(int n); void printf_back(); int load(); void printf_face(); int i,n,c; n=load(); do for(i=0;in;i+) if(roomi.sign=1) printf(room%s has been fulln,roomi.room_id); else puts(nregister new recordn); printf(n room%s is empty,roomi.room_id); printf(nplease enter room%ss information,roomi.room_id); puts(nplease enter customers namen); scanf(%15s,&roomi.client_list.name); printf(nplease enter sex and agen); scanf(%3d %3d,&roomi.client_list.sex,&room i.client_list.age); puts(nplease enter customers id_cardn); scanf(%20s,&roomi.client_list.id_card); printf(nplease enter year and month and daten); scanf(%5d %5d %5d,&room i.client_list.year,&roomi.client_list.month,&room i.client_list.date); roomi.sign=1;/把房间标记为已满 printf_face(); printf_one(i); printf(nn are you sure?nnt1.suret2.cancle and againt3.back without save bb); scanf(%d,&c); if(c=1) save(n); printf_back(); else if(c!=2) menu(); while(c=2);return_confirm(); int load() file *fp; int i; if(fp=fopen(hotel.txt,r)=null) printf(ncannot open filen); exit(0); for(i=0;!feof(fp);i+) fscanf(fp,n%s%s%d%d%s%d%d%s%d%d%dn,&room i.room_id,&roomi.tel,&roomi.price, &roomi.sign,&roomi.client_list.name,&room i.client_list.sex, &roomi.client_list.age,&room i.client_list.id_card, &roomi.client_list.year,&room i.client_list.month,&roomi.client_list.date); fclose(fp); return(i); void printf_one(int i) printf(n%-5s %5s %5d %d, roomi.room_id,roomi.tel,room i.price,roomi.sign); printf(n%-s %5d %5d %10s,roomi.client_list.name,room i.client_list.sex,roomi.client_list.age,roomi.client_list.id_card); printf(n%-5d %5d %5dn, roomi.client_list.year,room i.client_list.month,roomi.client_list.date); void save(int n) file *fp; int i; if(fp=fopen(hotel.txt,w)=null) printf(ncannot open filen); exit(0); for(i=0;inn1).time2).room_id 3) price); printf(which you need?: bb); scanf(%d,&c); if(c3|c3|c1); switch(c) case 1:time_stati();break; case 2:room_id_stati();break; case 3:price_stati();break; return_confirm(); void time_stati() /*统计入住的时间*/ int n,i,k=0,w,w0=1,w2=0; struct hotel s; n=load(); do do w=-1; puts(nplease enter the time that you want to statistic.n); puts(nplease enter the year:); scanf(%d,&s.client_list.year); puts(nplease enter the month:); scanf(%d,&s.client_list.month); puts(nplease enter the date:); scanf(%d,&s.client_list.date); for(i=0,k=0;in;i+) if(s.client_list.year=room i.client_list.year&s.client_list.month=room i.client_list.month&s.client_list.date=roomi.client_list.date) w=i; printf_face(); printf_one(i); k+; printf(nthere are %d recorders this day!,k); if(w=-1) printf(nno exist!please. enter error!); printf(nthere are no recorders this day!); printf(ndo you want to retry another?nnt1).yes 2).no and back 3).back to menu bb); scanf(%d,&w0); if(w0=2) stati(); else if(w0!=1) menu(); else printf(nsuccessful!_ _.nenter another time?nnt1).yes 2).back to menut bb); scanf(%d,&w2); if(w2!=1) menu(); while(w=-1&w0=1); while(w2=1); void room_id_stati() /*统计房间号*/ int n,i,k=0,w,w0=1,w2=0; struct hotel s; n=load(); do do w=-1; puts(nplease enter the room_id that you want to statistic.n); scanf(%s,&s.room_id); for(i=0,k=0;in;i+) if(strcmp(s.room_id,roomi.room_id)=0) w=i; printf_face(); printf_one(i); k+; printf(nthere are %d recorders in this room!,k); if(w=-1) printf(nno exist!please. enter error!); printf(nthere are no recorders in this room!); printf(ndo you want to retry another?nnt1).yes 2).no and back 3).back to menu bb); scanf(%d,&w0); if(w0=2) stati(); else if(w0!=1) menu(); else printf(nsuccessful! _ _.nenter another room_id?nnt1).yes 2).back to menut bb); scanf(%d,&w2); if(w2!=1) menu(); while(w=-1&w0=1); while(w2=1); void price_stati() /*统计房间单价*/ int n,i,k=0,w,w0=1,w2=0; struct hotel s; n=load(); do do w=-1; puts(nplease enter the rooms price that you want to statistic.n); scanf(%d,&s.price); for(i=0,k=0;in;i+) if(s.price=roomi.price) w=i; printf_face(); printf_one(i); k+; printf(nthere are %d recorders at this price!,k); if(w=-1) printf(nno exist!please. enter error!); printf(nthere are no recorders at this price!); printf(ndo you want to retry another?nnt1).yes 2).no and back 3).back to menu bb); scanf(%d,&w0); if(w0=2) stati(); else if(w0!=1) menu(); else printf(nsuccessful!.nenter another roomprice?nnt1).yes 2).back to menut bb); scanf(%d,&w2); if(w2!=1) menu(); while(w=-1&w0=1); while(w2=1); 本函数的功能为输出统计功能菜单选项,包括根据按性别统计、根据年龄统计及根据入住时间统计。系统根据输入的选项执行相应的函数。(3)查找模块程序: void search() /*查找函数*/ int i,n,k,w1=1,w2,w3; struct hotel s; n=load(); do w2=-1; do k=-1; printf(nnenter id_card that you want to search! id_card:); scanf(%s,&s.client_list.id_card); for(i=0;in;i+) if(strcmp(s.client_list.id_card,room i.client_list.id_card)=0) k=i; w2=1; printf_one(k); break; if(k=-1) printf(nnno exit!please.); printf(nnare you again ?nt1).again 2).no and back bb); scanf(%d,&w1); if(w1!=1) menu(); while(k=-1&w1=1); if(w2=1) printf(nnsuccessful._.n); printf(nwhat do you want to do?nt1).search another 2).back to menu bb); scanf(%d,&w3); if(w3!=1) menu(); while(w3=1); 本函数的功能为输出查询功能菜单选项,包括根据房间号查询、根据姓名查询及根据性别查询。系统根据输入的选项执行相应的函数。(4)修改模块需求分析 该模块的功能是插入客户记录信息并且不能覆盖原有客户信息。程序:void modify() /*修改函数*/ int modify_date(int i,int k); struct hotel s; int i,n,k,w0=1,w1,w2=0; n=load(); do k=-1; printf_face(); for(i=0;in;i+) if(i!=0)&(i%4)=0) printf(nnremember room_id that you need to modify! pass any key to continue .); getchar(); puts(nn); printf_one(i); do printf(nnenter room_id that you want to modify!room_id:); scanf(%s,s.room_id); for(i=0;inn 1).name 2).sex 3).agen 4).id_card 5).time 6).all data 7).cancle and back); printf(which you need?: bb); scanf(%d,&c); if(c7|c7|c1); do switch(c) case1:printf(please enter new name:);scanf(% s,&roomi.client_list.name);break; case 2:printf(please enter new sex:);scanf(% d,&roomi.client_list.sex);break; case 3:printf(please enter new age:);scanf(% d,&roomi.client_list.age);break; case4:printf(pleaseenternewid_card:);scanf(%s,&roomi.client_list.id_card);break; case5:printf(pleaseenternewyearmonthdate:);scanf(%d%d%d,&roomi.client_list.year,&roomi.client_list.month,&room i.client_list.date);break; case 6:printf(please enter new all data:); puts(nplease enter customers new namen); scanf(%15s,&roomi.client_list.name); printf(nplease enter new sex and agen); scanf(%3d %3d,&roomi.client_list.sex,&room i.client_list.age); puts(nplease enter new customers id_cardn); scanf(%20s,&roomi.client_list.id_card); printf(nplease enter new year and month and daten); scanf(%5d %5d %5d,&room i.client_list.year,&roomi.client_list.month, &roomi.client_list.date);break; case 7:menu(); puts(nnow ,please ensure the information you entered.); printf_face(); printf_one(i); pr
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 肝部分切除护理查房流程
- 2025年入团考试战略分析试题及答案
- 人教版高考英语必练题总结模版
- 《胸部肿瘤精准治疗策略》课件
- 安全员个人年终总结模版
- 《药物监管策略》课件
- 《听觉感知训练》课件
- 【培训课件】企业文化培训(尚泽)
- 可爱的小鸡创意画课件
- 2025办公设备采购合同
- 四等水准测量自动生成表格
- 2023全国新高考1卷英语听力
- 《建筑与市政工程防水通用规范》解读培训
- 小学美术-形的魅力教学设计学情分析教材分析课后反思
- 上海建设路桥破碎机图纸目录-成套-CAD-图纸
- 穴位埋线疗法疗法
- 井下动火安全技术措施
- 理解词语句子的方法PPT
- 热线心理咨询技术-课件
- 碰撞与冲击动力学
- 全等三角形第一课时课件
评论
0/150
提交评论