版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、 中国地质大学(武汉)C语言课程设计论文学 院: 专 业: 题 目: 客房管理系统设计 班 级: 姓 名: 学 号: 指导教师: 2010年9月6日 报告目录报告目录1报告摘要2一、题目要求3二、需求分析3三、总体设计3四、详细设计41、主函数部分:42、各功能模块函数部分:6(1)输入模块6(2)统计模块7(3)查找模块10(4)修改模块123、公共函数部分:16(1)保存函数 save()16(2)加载函数 load_room()16(3)一个任务结束时的选择函数printf_back()17(4)修改整条数据记录函数modify_data(int i,int n)17五、上机操
2、作18总结21 报告摘要此次C语言课程设计我选择的是客房管理系统设计,系统设计采用c语言在microsoft visual c+6.0下编译而成。客房管理系统包括客户基本信息的录入、统计、查询、修改功能。系统开发由分析、设计、实施、调试和测试等阶段组成,其中信息管理为开发的重点。在程序设计中结构体的调用与文件的读写为编译的重点部分。一、题目要求客户信息包括身份证号、姓名、性别、年龄、房间号。试设计一客房管理系统,使之能提供以下功能:(1) 系统以菜单方式工作(2) 客户信息录入功能(客户信息用文件保存)(3) 客户信息统计功能(4) 客户信息查询功能,查询方式(5) 客户信息修改功能(可选项)
3、 建立客户信息结构体,结构体成员包括身份证号、姓名、性别、年龄、房间号提示 二、需求分析根据题目要求,要求对客户信息进行输入、输出等操作;在程序中需要浏览客户的信息,应提供显示、统计、查询、修改等操作;另外还应提供键盘式选择菜单实现功能选择。三、总体设计根据需求分析,可以对这个系统的设计分为以下几个模块:客户信息管理系统数据输入数据统计数据查询数据修改数据删除系统功能模块图四、详细设计1、主函数部分:主函数一般设计得比较简洁,只提供输入,处理和输出部分的函数调用。其中各功能模块用菜单方式选择。并使用蓝色作为背景颜色。流程图:显示各功能选项根据 n的值调用各功能模块函数NY输入n ,判断n 是否
4、是0-5主函数流程图main() /*主函数*/ int i;puts("欢迎进入:");for (i=0;i<100;i+)system("color 1f");printf("nnnnntt客房管理系统");printf("nnntttPress any key to continue.");printf("nnnnnnnnnnnntttttttt-By童川n");getch(); menu(); void menu() /*菜单函数*/int n,w;doputs("nnn
5、t*MENU*nn");puts("ttt |(1).Regist |n");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",&
6、amp;n);if(n<1|n>5) w=1,getchar();else w=0;while(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
7、age; char ID_card20; /*居民身份证*/ int year; int month; 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();
8、void load_room();void modify_day();void modify_s(int 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
9、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");scanf("%d",&roomi.room_ID); puts("ntTel:t");scanf("%s",roomi.tel); puts("ntPrice:t&
10、quot;);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 men | 0 for women):t");scanf("%d",&roomi.client_listj.sex); puts("ntAge:t");scanf("%d&q
11、uot;,&roomi.client_listj.age); puts("ntID_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"
12、);scanf("%d",&roomi.client_listj.date); 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 ro
13、omn");puts("tttt3).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:stat_o();break; case 2:stat_u();break; case 3:menu(); void stat_o()
14、/*统计人数*/int j,i,n,l;int s=0;puts("Please input 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&q
15、uot;);puts("1).Statistics againt2).backn");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
16、 do?n");puts("1).Statistics againt2).backn");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&
17、quot;,roomi.client_listj.age);puts("nID_card:");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&qu
18、ot;,roomi.room_ID);printf("nTel:%sn",roomi.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
19、erev lived heren");puts("tt2).Search someday 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();brea
20、k; case 2:search_day();break; case 3:menu();void search_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(&q
21、uot;nThere is no record heren"); puts("What 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 w
22、ant to search");printf("nYear:"); scanf("%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
23、.month=b)&&(roomi.client_listj.year=a) w=1,m=i,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)修改模块需求分析 该模
24、块的功能是插入客户记录信息并且不能覆盖原有客户信息。流程图 插入模块调用加载函数让用户输入要插入的客户信息个数调用整条信息输入函数用户作出选择,输入1or21还是21 浏览全部2返回主菜单修改模块流程图程序: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&q
25、uot;);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: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("t
26、tPlease input the name");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"); modify_s(m,n); save();puts("What you want to do?n");puts(&
27、quot;1).Modify againt2).backn");scanf("%d",&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).d
28、ate 8).room_ID 9)tel 10).price 11).modify nonen");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 ne
29、w sexn");scanf("%d",&a);roomi.client_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,
30、s);break; case 5:printf("Please input new yearn");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(
31、"%d",&a);roomi.client_listj.date=a;break; 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 inp
32、ut the new pricen");scanf("%d",&a);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
33、("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,n=j;if(w=1) printf_p(m,n);else printf("NO record this dayn");modify_s(m,n);sa
34、ve();puts("What you want to do?n");puts("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("nCanno
35、t open filen"); return NULL;for(i=0;i<r;i+) for(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.
36、client_listj.month,roomi.client_listj.date);fclose(fp);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+)
37、 for(j=0;!feof(fp);j+)fscanf(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); r=i; 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)
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年项目合作人工智能算法开发合同
- 2026年物流加盟猎头招聘合同
- 2026年汕头市潮阳区广播电视台(融媒体中心)人员招聘考试备考题库及答案解析
- 2026年厦门市思明区广播电视台(融媒体中心)人员招聘笔试备考试题及答案解析
- 2026年企业人力资源管理师考试题库及参考答案详解【满分必刷】
- 2026年遵义市汇川区林业系统人员招聘考试参考试题及答案解析
- 2026年山东省枣庄市广播电视台(融媒体中心)人员招聘笔试参考试题及答案解析
- 2026年遂宁市船山区广播电视台(融媒体中心)人员招聘笔试备考试题及答案解析
- 2026年喀什地区广播电视台(融媒体中心)人员招聘笔试备考试题及答案解析
- 2026年辽宁省沈阳市广播电视台(融媒体中心)人员招聘笔试参考试题及答案解析
- 2026江苏苏州市健康养老产业发展集团有限公司下属子公司招聘15人(第二批)笔试参考试题及答案解析
- 2026贵州黔西南技师学院公开招聘事业单位工作人员14人考试备考试题及答案解析
- 历史(四川卷)(考试版)-2026年高考考前预测卷
- 2026年佳木斯富锦市市政设施管护中心公开招聘一线工程技术人员3人笔试备考试题及答案解析
- 大学生创新创业基础(广西师范大学)知到知识点掌握度满分答案题库
- 2026年江苏泰州市初二学业水平地生会考试卷题库及答案
- 瑞幸咖啡2025品牌年终报告
- 初中化学九年级下册“化学与社会·跨学科实践”单元整体建构教案
- 2026年广西事业单位招聘面试真题及答案
- 2026年高性能医用新材料研发与生物安全性评价
- 党员之家内部管理制度
评论
0/150
提交评论