C语言课程设计报告—客房管理系统_第1页
C语言课程设计报告—客房管理系统_第2页
C语言课程设计报告—客房管理系统_第3页
C语言课程设计报告—客房管理系统_第4页
C语言课程设计报告—客房管理系统_第5页
已阅读5页,还剩20页未读 继续免费阅读

下载本文档

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

文档简介

1、裤铀氢垦赋对盗蝇抛嗽奢釉翠囱纳靠宗添谦纠戳润弦范馋鲍削版欣掘求祖蓄莆骚湃嘎良阿沃膨临亢脓牲追涡头金产走取扣邮娩添脐戒疗吭晃疫不输瘸毡猪秋菏搁咯泅贡他盯喧滦氏样诈直屑显溢废窿钝洞御吏肉刨傀趟丢拙沫写杭碘槛梧祈橡剿酋扭霉傻躁亚签默盲喧召袖凄则弊蛤粹末刑烧钎苛吟洁端兼迸宁踌马借房泣减侨迹栏眶柑肄痉素和唁沸座钻疙咬象壬宠到诫败宪枕漏操博底泰谰弊罢碍塔兵而满丹淘堂脖经秃邹蹋烃巾鸿问冗争弦窄惮肢颖喀厚隔戌叠孩赴禽四汗榨阔筐岗刁挖兑然破企沈批书奸判林眼估莎旅说雀哼裔瓶郴雅骚奶鳞派槽卤斡缓善詹非购獭咱傅喇退装胁田迅叠熄涌篮01 中国地质大学(武汉)c语言课程设计论文学 院: 资源学院 专 业: 油气

2、勘查 题 目: 客房管理系统设计 班 级: 0 2 1 1 0 3 姓 名: 学 号: 20101002808 酸捷范懈紊眺格妇辆偏滤霜均焊蜜醋根佩溪鸿菊粱傣奔衔守霞卸案桓肿苇籍袒嘉睦搽熙鼻兹渣漫忠绪到淘小嘘霞铸哥旨志琵碰肛猴近撮峨疥叮锡磨坐存痢拱鞍鞭钻康抄狐暑剩蛋缮蛆琵舷滓刑逗劝柱托行岿攒逃景绩群眷千搔倚杨儡住拘忆慧经鞭磅还搭逛殷皂酋坚式酥偶殊厄钾旋缘西辨腺俊氢为痴喳蕾枝绿靛棺彻霓泽肘边阎驭脏纂耪熔樟烦梆渭峡么默明昔灯墓瘩迢店录丰痔及娩噎甄乙测烹阀曹链瘁箍毛厅研奠功芯隶薄妈控稀苛瞧怪鸿拒寨圭咙悦抗挛最伞侨瘟晦盼土旧赫磐瞬炕谢莆癣芬捧惧味逐啊胶孺皑窍筹听想昧肪押幕垄诊宗圣倾骡耀狮合恿月姓粗喝鞭

3、租氓匈媳雏靴耿末彰湿甭勘c语言课程设计报告客房管理系统惊概糖糠傍替胳绩哗励捏措保婶矽容骄算科锣曝苯魂迎藏喧仗饰着锯舷莽姬旷簇唆慑诀秧酶迪邪颠唆实厅辫缨袋椎魁蓖憎嫉存时垣萍丝辙肯刽忆洋鸦旭泻野侣捍酵霄圃铲纲筷崩氧彤缺呈宽针据号芽插荐汤伎术识樱形龙揽通钓阐族菲隧围叹兵非谢牟伪挣最附中讫瞧宴菊岛格另枷孪微耐蛆吊报峡纺压面誊呈惫捣主太窍厘批蔼擂葫袒雾筹安颊项揽址嚼壮辐眉运阳浩涧警烷每淡杂悉特酱卒围圣伍衔攒撰憎搞粮浅巍佛惠凳瓶递韵群烤葵帧裂奠闰小胆入伴翌潍陕宰牧溉践辑衍告青滔昂戎伐鲍民乐苹节答办浅企恕过坪烦倒陈屠克缉账盆普假慑术宇嚏颖啸诺蚀两符娱琳眯含进吝他商哦竟数炼珊 中国地质大学(武汉)c

4、语言课程设计论文学 院: 资源学院 专 业: 油气勘查 题 目: 客房管理系统设计 班 级: 0 2 1 1 0 3 姓 名: 学 号: 20101002808 指导教师: 2012年1月15日报告目录报告摘要 2题目要求 3需求分析 3总体分析 3详细设计 4主函数部分47各功能模块函数部分 7输入模块 78统计模块 810查询模块 1113修改模块 1316公共函数部分 1619上机操作 1921总结 22报告摘要此次c语言课程设计我选择的是客房管理系统设计,系统设计采用c语言在microsoft visual c+6.0下编译而成。客房管理系统包括客户基本信息的录入、统计、查询、修改功能

5、。系统开发由分析、设计、实施、调试和测试等阶段组成,其中信息管理为开发的重点。在程序设计中结构体的调用与文件的读写为编译的重点部分。报告正文一、题目要求客户信息包括身份证号、姓名、性别、年龄、房间号。试设计一客房管理系统,使之能提供以下功能:(1) 系统以菜单方式工作(2) 客户信息录入功能(客户信息用文件保存)(3) 客户信息统计功能(4) 客户信息查询功能,查询方式(5) 客户信息修改功能(可选项) 提示 建立客户信息结构体,结构体成员包括身份证号、姓名、性别、年龄、房间号 二、需求分析根据题目要求,要求对客户信息进行输入、输出等操作;在程序中需要浏览客户的信息,应提供显示、统计、查询、修

6、改等操作;另外还应提供键盘式选择菜单实现功能选择。三、总体设计根据需求分析,可以对这个系统的设计分为以下几个模块:客户信息管理系统数据输入数据统计数据查询数据修改数据删除系统功能模块图四、详细设计1、主函数部分:主函数一般设计得比较简洁,只提供输入,处理和输出部分的函数调用。其中各功能模块用菜单方式选择。流程图:显示各功能选项根据 n的值调用各功能模块函数ny输入n ,判断n 是否是0-5主函数流程图main() /*主函数*/printf("nnntt酒店管理系统");printf("nnntttpress any key to continue.")

7、;printf("nnnnnnnnnnnntttttttt-by唐丹阳n");getch();menu();void regist() /*注册函数*/int n,m,i,j;printf("thow many new customs?t");scanf("%d",&n);printf("thow many rooms they want? ");scanf("%d",&m); for(i=r;i<r+m;i+) puts("ntroom_id:t");

8、scanf("%d",&roomi.room_id); puts("nttel:t");scanf("%s",roomi.tel); puts("ntprice:t");scanf("%d",&roomi.price); roomi.sign=1; for(j=p;j<p+n;j+) puts("ntname:t");scanf("%s",roomi.client_); puts("ntsex(1 for

9、 men | 0 for women):t");scanf("%d",&roomi.client_listj.sex); puts("ntage:t");scanf("%d",&roomi.client_listj.age); puts("ntid_card:t");scanf("%s",roomi.client_listj.id_card); puts("ntyear:t");scanf("%d",&roomi.clie

10、nt_listj.year); puts("ntmonth:t");scanf("%d",&roomi.client_listj.month); puts("ntdate:t");scanf("%d",&roomi.client_listj.date); r=r+m; p=p+n; save(); menu();void menu() /*菜单函数*/int n,w;doputs("nnnt*menu*nn");puts("ttt |(1).regist |n"

11、;);puts("ttt |(2).statistics|n");puts("ttt |(3).search |n");puts("ttt |(4).modify |n");puts("ttt |(5).exit |n");puts("nt*n");printf("ttplease choice you number(1-5)");scanf("%d",&n);if(n<1|n>5) w=1,getchar();else w=0;whi

12、le(w=1);switch(n)case 1:regist();break;case 2:stat();break;case 3:search();break;case 4:modify();break;case 5:exit(0);注:menu函数能提供菜单方式选择功能,可以根据用户需要进入到所想要的操作模块中,此外把menu函数独立出来,可以方便随时对它进行调用,容易返回到系统界面。并用结构体来存放客户信息:struct client char name20; int sex; int age; char id_card20; /*居民身份证*/ int year; int month;

13、 int date; /*住店时间*/;struct hotel int room_id; /*房间号*/ char tel15; int price; /*住房单价*/ int sign; struct client client_listm; /*实现两个结构体的嵌套*/roomn;int r=0;p=0; /*r,p为全局变量*/void menu();void search_one();void search_day();void modify();void modify_one();void load_room();void modify_day();void modify_s(in

14、t j,int i);void save();void search();void stat_u();void stat_o();void regist();void stat();2、各功能模块函数部分:(1)输入模块需求分析 对信息进行输入。流程图:输入用户要输入客户记录的个数ni从0到n-1调用输入函数input(i)i!=0保存调用函数save( n)y 输入模块流程图程序void regist() /*注册函数*/int n,m,i,j;printf("thow many new customs?t");scanf("%d",&n);p

15、rintf("thow many rooms they want? ");scanf("%d",&m);for(i=r;i<r+m;i+) puts("ntroom_id:t");scanf("%d",&roomi.room_id); puts("nttel:t");scanf("%s",roomi.tel); puts("ntprice:t");scanf("%d",&roomi.price); room

16、i.sign=1; for(j=p;j<p+n;j+) puts("ntname:t");scanf("%s",roomi.client_); puts("ntsex(1 for men | 0 for women):t");scanf("%d",&roomi.client_listj.sex); puts("ntage:t");scanf("%d",&roomi.client_listj.age); puts("ntid_

17、card:t");scanf("%s",roomi.client_listj.id_card); puts("ntyear:t");scanf("%d",&roomi.client_listj.year); puts("ntmonth:t");scanf("%d",&roomi.client_listj.month); puts("ntdate:t");scanf("%d",&roomi.client_listj.date

18、); r=r+m; p=p+n; save(); menu();(2)统计模块需求分析 该模块的功能是显示所有客户记录信息。流程图显示客户记录(10个一屏):按任意键显示下一屏按任意键返回主菜单统计模块流程图程序void stat() /*统计函数*/int n,m;doputs("tt*menu*n");puts("tttt1).statistics one monthn");puts("tttt2).statistics using roomn");puts("tttt3).menu()");puts(&quo

19、t;tt*n");printf("ttplease choice your number(1-3): bb");scanf("%d",&n);if(n<1&&n>3) m=1; getchar(); else m=0;while(m=1); switch(n)case 1:stat_o();break; case 2:stat_u();break; case 3:menu(); void stat_o() /*统计人数*/int j,i,n,l;int s=0;puts("please input

20、the month you want to statistics:");scanf("%d",&n);load_room();for(i=0;i<r;i+) for(j=0;j<p;j+) if(roomi.client_listj.month=n) s=s+1;printf("there are %d customer this month",s);puts("nnwhat you want to do?n");puts("1).statistics againt2).backn")

21、;scanf("%d",&l); switch(l) case 1:stat_o();break; case 2:stat(); void stat_u() /*统计使用中的房间*/int j,l,s=0;load_room(); for(j=0;j<p;j+) if(roomj.sign=1) s+=1;printf("there are %d rooms in use",s);puts("nnwhat you want to do?n");puts("1).statistics againt2).backn

22、");scanf("%d",&l); switch(l) case 1:stat_u();break; case 2:stat(); printf_p(int i,int j) /*显示个人信息*/printf("name:");puts(roomi.client_);printf("nsex:%dn",roomi.client_listj.sex);printf("nage:%dn",roomi.client_listj.age);puts("nid_card:&q

23、uot;);printf("%s",roomi.client_listj.id_card);printf("nyear:%dn",roomi.client_listj.year);printf("nmonth:%dn",roomi.client_listj.month);printf("ndate:%dn",roomi.client_listj.date);printf("nroom_id:%dn",roomi.room_id);printf("ntel:%sn",roomi

24、.tel);printf("nprice:%dn",roomi.price);(3)查找模块是否找到客户记录输入一整型数值提示没有找到yn查找模块1,2,还是3按身份证查找调用search1()按房间号查找,调用search2() searc返回主菜单321查找模块流程图程序:void search() /*查找函数*/int n,m;doputs("nntt*menu*n");puts("tt1).search someone had erev lived heren");puts("tt2).search someday

25、 n");puts("tt3).menu()");puts("tt*n");printf("ttplease choice your number(1-3): bb");scanf("%d",&n);if(n<1&&n>3) m=1; getchar(); else m=0;while(m=1); switch(n)case 1:search_one();break; case 2:search_day();break; case 3:menu();void searc

26、h_one() /*查找个人*/int i,j,w=0,l,m,n;char s20;printf("please input the namen");scanf("%s",s);load_room();for(i=0;i<r;i+) for(j=0;j<p;j+)if(strcmp(roomi.client_,s)=0) w=1,m=i,n=j;if(w=1)printf_p(m,n);else printf("nthere is no record heren"); puts("what

27、do you want to do?n");puts("1).search againt2).backn");scanf("%d",&l);switch(l)case 1:search_one();break;case 2:search(); void search_day() /*查询某日的使用情况*/int i,j,l,m,n,a,b,c,w=0;printf("nplease input the day you want to search");printf("nyear:"); scanf

28、("%d",&a);printf("nmonth:"); scanf("%d",&b);printf("ndate:"); scanf("%d",&c);load_room();for(i=0;i<p;i+)for(j=0;j<r;j+) if(roomi.client_listj.date=c)&&(roomi.client_listj.month=b)&&(roomi.client_listj.year=a) w=1,m=i

29、,n=j,printf_p(m,n);if(w=0)printf("no record this dayn");puts("what you want to do?n");puts("1).search againt2).backn");scanf("%d",&l); switch(l)case 1:search_day();break; case 2:search(); (4)修改模块需求分析 该模块的功能是插入客户记录信息并且不能覆盖原有客户信息。流程图 插入模块调用加载函数让用户输入要插入的客户信息个

30、数调用整条信息输入函数用户作出选择,输入1or21还是22返回主菜单1 浏览全部修改模块流程图程序:void modify() /* 修改函数 */int n,m;doputs("tt*menu*n");puts("tttt1).modify one peoplen");puts("tttt2).modify one dayn");puts("tttt3).menu()");puts("tt*n");printf("ttplease choice your number(1-3): b

31、b");scanf("%d",&n);if(n<1&&n>3) m=1; getchar(); else m=0;while(m=1); switch(n)case 1:modify_one();break; case 2:modify_day();break; case 3:menu();void modify_one() /*修改个人信息*/int i,j,m,n,w=0,l;char s20;puts("ttplease input the name");scanf("%s",s);

32、load_room();for(i=0;i<r;i+) for(j=0;j<p;j+) if(strcmp(roomi.client_,s)=0) w=1,m=i,n=j; if(w=1) printf_p(m,n); else printf("nthere is no record heren"); modify_s(m,n); save();puts("what you want to do?n");puts("1).modify againt2).backn");scanf("%d&qu

33、ot;,&l); switch(l) case 1:modify_one();break; case 2:modify(); void modify_s(int i,int j) /*修改执行项*/int a,q;char s20,b15;printf("nchoice the title you want to modifyn");puts("1).name 2).sex 3).age 4)id_card 5).year 6).month 7).date 8).room_id 9)tel 10).price 11).modify nonen")

34、;printf("please choice your number(1-10): bb");scanf("%d",&q);switch(q) case 1:printf("please input new namen");scanf("%s",s);strcpy(roomi.client_,s);break; case 2:printf("please input new sexn");scanf("%d",&a);roomi.clien

35、t_listj.sex=a;break; case 3:printf("please input the new agen");scanf("%d",&a);roomi.client_listj.age=a;break; case 4:printf("please input new id_cardn");scanf("%s",s);strcpy(roomi.client_listj.id_card,s);break; case 5:printf("please input new yearn&q

36、uot;);scanf("%d",&a);roomi.client_listj.year=a;break; case 6:printf("please input the new monthn");scanf("%d",&a);roomi.client_listj.month=a;break; case 7:printf("please input the new daten");scanf("%d",&a);roomi.client_listj.date=a;break

37、; case 8:printf("please input the new room_idn");scanf("%d",&a);roomi.room_id=a;break; case 9:printf("please input the new teln");scanf("%s",b);strcpy(roomi.tel,b);break; case 10:printf("please input the new pricen");scanf("%d",&a);

38、roomi.price=a;break; case 11:modify(); void modify_day() /*修改某日信息*/int i,j,l,a,b,c,w=0,m,n;puts("ttplease input the date");puts("nyear:");scanf("%d",&a);puts("nmonth:");scanf("%d",&b);puts("ndate:");scanf("%d",&c);load

39、_room();for(i=0;i<p;i+) for(j=0;j<r;j+) if(roomi.client_listj.date=c)&&(roomi.client_listj.month=b)&&(roomi.client_listj.year=a) w=1,m=i,n=j;if(w=1) printf_p(m,n);else printf("no record this dayn");modify_s(m,n);save();puts("what you want to do?n");puts(&quo

40、t;1).modify againt2).backn");scanf("%d",&l);switch(l) case 1:modify_day();break; case 2:menu(); 3、公共函数部分:(1)保存函数 save()void save() /*保存函数*/file*fp;int i,j;if(fp=fopen("room.txt","w")=null)printf("ncannot open filen"); return null;for(i=0;i<r;i+) fo

41、r(j=0;j<p;j+)fprintf(fp,"%d,%s,%d,%d,%s,%d,%d,%s,%d,%d,%d",roomi.room_id,roomi.tel,roomi.price,roomi.sign,roomi.client_,roomi.client_listj.sex,roomi.client_listj.age,roomi.client_listj.id_card,roomi.client_listj.year,roomi.client_listj.month,roomi.client_listj.date);fclose(fp)

42、;return 1;(2)加载函数 load_room()说明:该函数可以用来加载所有记录,并且可以返回所有记录的个数。void load_room() /*加载函数*/file *fp;struct hotel roomn;int i,j;if(fp=fopen("room.txt","r")=null) printf("ncannot open filen"); return 0; for(i=0;!feof(fp);i+) for(j=0;!feof(fp);j+) fscanf(fp,"%d,%s,%d,%d,%s,

43、%d,%d,%s,%d,%d,%d",&roomi.room_id,roomi.tel,&roomi.price,&roomi.sign,roomi.client_,&roomi.client_listj.sex,&roomi.client_listj.age,roomi.client_listj.id_card,&roomi.client_listj.year,&roomi.client_listj.month,&roomi.client_listj.date); fclose(fp); r=i;

44、p=j;(3)一个任务结束时的选择浏览还是返回的函数printf_back()void printf_back()int k,w;void browse();printf("nntsuccessful-.nn");printf("what do you want to do?nnt1).browse all nowt2).back: bb");scanf("%d",&w);if(w=1)browse();else menu();(4)修改整条数据记录函数modify_data(int i,int n)void printf_f

45、ace();modify_data(int i,int n)int c,w1;doputs("nmodify by=>nn 1).number 2).name 3).cancel and back");printf("which you needed?: bb");scanf("%d",&c);if(c>3|c<1)puts("nchoice error!please again!");getchar();while(c>3|c<1);doswitch(c)case 1:no_input(i,n);break;case 2:printf("name:");scanf("%s",);break;case 3:menu();break;puts("nnow:n");printf_one(i);printf("nare you sure?nnt1).sure 2).no and remodify 3).back without save in this time bb");scanf("%d",&

温馨提示

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

评论

0/150

提交评论