客房管理系统—C语言_第1页
客房管理系统—C语言_第2页
客房管理系统—C语言_第3页
客房管理系统—C语言_第4页
客房管理系统—C语言_第5页
已阅读5页,还剩17页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、三峡大学理学院 2010 级电子信息科学与技术专业高级语言程序设计 课程设计说明书设计题目 :客房管理系统班级 :20101421学号 :2010142139姓名 :徐晶完成日期 :2011-11-23目录一、 任 (2)二、 需求分析 (2)三、 系 模 (2)四、 模 明 (3)五、 用 明(18)六、 果(18)七、 小 (19)八、 参考目 (19)一、 任 :客房管理系统实现用户登记功能,要提供结构体的输入操作,实现统计功能,要提供相应的统计操作,实现查询功能,要提供查找操作,实现修改功能,要提供修改操作;另外还有提供键盘式菜单实现功能选择。二、需求分析 :1. 总体分析:整个客房管

2、理系统被设计为用户登记模块,统计模块,查询模块,和修改模块。2. 详细分析:( 1)用户登记模块 提示用户输入自身信息以及客房信息, 把数据存入 room 数组中。( 2)统计模块 18 设置计数器,顺序遍历 room 数组来实现,实现对房客数、某一天的房客数的统计。( 3)查询模块 通过基本查找算法查找 room 数组,可以按房间号、价格、房间标记、用户姓名、居民身份证查询。( 4)修改模块 采用基本查找算法在数组找到要修改的数据。三、系统模块图根据需求分析,可以对这个系统的设计分为以下几个模块:客户信息管理系统数据输入数据统计数据查询数据修改数据删除四、模块说明 :一个较大的 c 语言程序

3、不外乎由多个函数组成, 本程序也并不例外。现就本程序中涉及的各个函数的代码和功能分别进行说明。1、 主函数部分:程序:void main()/* 主函数 */int n,w;menu();doprintf(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);v

4、oid 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 struc

5、t client 50charname20;intsex; /famale 0,male 1;intage;charid_card20;/* 居民身份 */intyear;intmonth;intdate;/* 住店 */;structhotelcharroom_id10;chartel10;intprice;intsign;structclientclient_list;/* 房 号 */* 住房 价 */* 两个 构体的嵌套*/roomnum;注: menu 函数能提供菜单方式选择功能,可以根据用户需要进入到所想要的操作模块中,此外把menu 函数独立出来,可以方便随时对它进行调用,容易返

6、回到系统界面。并用结构体来存放客户信息。2、各功能模块函数部分:( 1)输入模块: 需求分析 对信息进行输入程序:voidregist()/* 登 函数 */void printf_one(int i);void save(int n);void printf_back();int load();void printf_face();int i,n,c;n=load();dofor(i=0;in;i+)if(roomi.sign=1)printf(room%s has been fulln,roomi.room_id);elseputs(nregister new recordn);print

7、f(n room%s is empty,roomi.room_id);printf(npleaseenter 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);sc

8、anf(%20s,&roomi.client_list.id_card);printf(nplease enter year and month and daten);scanf(%5d%5d%5d,&roomi.client_list.year,&roomi.client_list.month,&roomi.client_list.date);roomi.sign=1;/ 把房间标记为已满printf_face();printf_one(i);printf(nnare you sure?nnt1.suret2.cancle and againt3.back withoutsave bb);s

9、canf(%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.clien

10、t_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,roomi.price,roomi.sign);printf(n%-s%5d%5d%10s,room

11、i.client_list.name,roomi.client_list.sex,roomi.client_list.age,roomi.client_list.id_card);printf(n%-5d%5d%5dn,roomi.client_list.year,roomi.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).ro

12、om_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();voidtime_stati()/*统计入住的时间*/int n,i,k=0,w,w0=1,w2=0;structhotels;n=load();dodow=-1;puts(nplease enter the time that you wan

13、t 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_li

14、st.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(ndoyou want to retry another?nnt1).yes 2).no and back 3).back tomenu bb);sc

15、anf(%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);voidroom_id_stati()/*统计房间号 */int n,i,k=0,w,w0=1,w2=0;structhotels;n=load();dodow=-1;puts(nplease enter the room_i

16、d 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 recordersif(w=-1)in this room!,k);printf(nno exist!please.enter error!);printf(nthere are no recordersin this room!);printf(ndoyou want

17、to retry another?nnt1).yes 2).no and back 3).back tomenu 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);voidprice_stati()/*统计房间单价*/int n,i,k=0,w,w0=1,

18、w2=0;structhotels;n=load();dodow=-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(n

19、there are no recorders at this price!);printf(ndoyou want to retry another?nnt1).yes 2).no and back 3).back tomenu bb);scanf(%d,&w0);if(w0=2)stati();else if(w0!=1)menu();elseprintf(nsuccessful!.nenteranotherroomprice?nnt1).yes2).backtomenut bb);scanf(%d,&w2);if(w2!=1)menu();while(w=-1&w0=1);while(w2

20、=1);本函数的功能为输出统计功能菜单选项,包括根据按性别统计、根据年龄统计及根据入住时间统计。系统根据输入的选项执行相应的函数。( 3)查找模块程序 :voidsearch()/*查找函数 */int i,n,k,w1=1,w2,w3;structhotels;n=load();dow2=-1;dok=-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,roomi.c

21、lient_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,&

22、w3);if(w3!=1)menu();while(w3=1);本函数的功能为输出查询功能菜单选项,包括根据房间号查询、根据姓名查询及根据性别查询。系统根据输入的选项执行相应的函数。( 4)修改模块 需求分析 该模块的功能是插入客户记录信息并且不能覆盖原有客户信息。程序:void modify()/*修改函数 */int modify_date(int i,int k);structhotels;int i,n,k,w0=1,w1,w2=0;n=load();dok=-1;printf_face();for(i=0;in;i+)if(i!=0)&(i%4)=0)printf(nnremembe

23、r room_id that you need to modify! pass any key to continue .);getchar();puts(nn);printf_one(i);doprintf(nnenter room_id that you want to modify!room_id:);scanf(%s,s.room_id);for(i=0;inn1).name 2).sex 3).agen 4).id_card 5).time 6).all data7).cancle and back);printf(which you need?: bb);scanf(%d,&c);

24、if(c7|c7|c1);doswitch(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

25、,&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(np

26、lease 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 anddaten);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);printf(nare you sure?nnt1).sure 2).no and remodify

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论