




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、三峡大学理学院2021级电子信息科学与技术专业?高级语言程序设计?课程设计说明书设计题目: 客房管理系统班级: 20211421学号: 2021142139姓名: 徐晶完成日期: 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(); do printf("ttPlease choice you number(1-5)"); scanf("%d",&n); if(n<1|n>5) 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、 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
5、) 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 mo
6、nth; int date; /*住店时间*/; struct Hotel char Room_ID10; /*房间号*/ char Tel10; int Price; /*住房单价*/ int Sign; struct Client Client_list; /*实现两个结构体的嵌套*/RoomNUM; 注:menu函数能提供菜单方式选择功能,可以根据用户需要进入到所想要的操作模块中,此外把menu函数独立出来,可以方便随时对它进行调用,容易返回到系统界面。并用结构体来存放客户信息。2、各功能模块函数局部:1输入模块:需求分析 对信息进行输入程序:void regist() /*登记函数*/
7、 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;i<n;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
8、.Room_ID); printf("nplease enter Room%s's information",Roomi.Room_ID); puts("nplease enter customer's Namen"); scanf("%15s",&Roomi.Client_list.Name); printf("nplease enter Sex and Agen"); scanf("%3d %3d",&Roomi.Client_list.Sex,&Ro
9、om i.Client_list.Age); puts("nplease enter customer's 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.Clie
10、nt_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
11、(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, &am
12、p;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
13、%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"
14、)=NULL) printf("nCannot open filen"); exit(0); for(i=0;i<n;i+) fprintf(fp,"%-5s %-15s %-5d %-5d %-15s %-5d %-5d %-20s %-5d %-5d %-5dn",Roomi.Room_ID,Roomi.Tel,Roomi.Price,Roomi.Sign, Roomi.Client_list.Name,Roomi.Client_list.Sex, Roomi.Client_list.Age,Roomi.Client_list.ID_card,
15、Roomi.Client_list.year, Roomi.Client_list.month,Roomi.Client_list.date); fclose(fp); void printf_face() printf("nRoom_ID Tel Price Sign"); printf("nName Sex Age ID_card"); printf("nyear month date"); void printf_back() int w; printf("nntSuccessful.-nn"); print
16、f("Do you want to back?nnt1).Yest2).No: bb"); scanf("%d",&w); if(w=1) menu(); 本函数的功能为登记用户及房间信息,包括姓名、性别、年龄、年份、月份、日期及身份证、。系统依次分配房间号并定义此房间为非空。管理员可根据具体情况登记相应用户人数的信息。在此申明由于本程序并未将用户信息存入磁盘,因此务必先登记用户信息再执行功能菜单中的其他功能。2统计模块:需求分析 该模块的功能是显示所有客户记录信息。程序:void stati() /*统计函数*/ void Time_stati
17、(); void Room_ID_stati(); void Price_stati(); int c; do puts("nnstatistic by =>nn1).Time2).Room_ID 3) Price"); printf("Which you need<1-3>?: bb"); scanf("%d",&c); if(c>3|c<1) puts("nChoice errror!Please again!"); getchar(); while(c>3|c<
18、;1); 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
19、 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;i<n;i+) if(s.Client_list.year=R
20、oom 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("n
21、There 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");
22、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
23、=0,k=0;i<n;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 wan
24、t 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&a
25、mp;&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 Room's price that you want to statistic.n"); scanf("%d",&s.Price); for(i=0,k=0;i<n;i+) if(s.Price=Roomi.Price) w=i; printf_f
26、ace(); 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"
27、;); scanf("%d",&w0); if(w0=2) stati(); else if(w0!=1) menu(); else printf("nSuccessful!.nEnter another Room'price?nnt1).Yes 2).Back to menut bb"); scanf("%d",&w2); if(w2!=1) menu(); while(w=-1&&w0=1); while(w2=1); 本函数的功能为输出统计功能菜单项选择项,包括根据按性别统计、根据年龄统计
28、及根据入住时间统计。系统根据输入的选项执行相应的函数。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;i<n;i+) if(strcmp(s.Client_list.ID_card,Ro
29、om 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");
30、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);
31、 struct Hotel s; int i,n,k,w0=1,w1,w2=0; n=load(); do k=-1; printf_face(); for(i=0;i<n;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 yo
32、u want to modify!Room_ID:"); scanf("%s",s.Room_ID); for(i=0;i<n;i+) if(strcmp(s.Room_ID,Roomi.Room_ID)=0) k=i; s=Roomi; if(k=-1) printf("nnNo exist! Please again"); while(k=-1); printf_face(); printf_one(k); w1=modify_date(k,n); if(w1=1) printf("nnSuccessful _ _.nAre
33、 you modify another?nnt1).Yes 2).Back with savet bb"); scanf("%d",&w0); w2=1; else w0=0; if(w2=1) Roomi=s; if(w0!=1&&w2=1) save(n); while(w0=1); menu(); int modify_date(int i,int k) int c,w1; do puts("nnmodify by =>nn 1).Name 2).Sex 3).Agen 4).ID_card 5).Time 6).Al
34、l data 7).Cancle and back"); printf("Which you need?: bb"); scanf("%d",&c); if(c>7|c<1) puts("nChoice errror!Please again!"); getchar(); while(c>7|c<1); do switch(c) case1:printf("Please enter new Name:");scanf("% s",&Roomi.C
35、lient_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&
36、quot;,&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 c
37、ustomer's 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 customer's ID_cardn"); scanf("%20s",&Roomi.Client_list.ID_card); printf("
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 玩具企业的品牌合作策略考核试卷
- 智能通风电器具行业标准制定与实施策略分析考核试卷
- 零售业顾客参与度提升策略考核试卷
- 装饰材料行业品牌推广案例分析考核试卷
- 网络安全集成服务与风险管理考核试卷
- 气道阻塞急救处理方法
- 青春期女孩卫生课
- 初中服装设计课件
- 创伤包扎急救培训
- 银行行业深度报告-险资银行板块配置研究-风格匹配正当其时
- 2025年教师招聘教师资格面试逐字稿初中体育教师招聘面试《途中跑》试讲稿(逐字稿)
- 英语新闽教版小学四年级下册全册教案
- 人才梯队培养计划
- 北斗创新设计导航知到智慧树章节测试课后答案2024年秋山东大学
- 数据结构(本)-002-国开机考复习资料
- 核医学检查技术知到智慧树章节测试课后答案2024年秋山东第一医科大学
- 【MOOC】经济法学-西南政法大学 中国大学慕课MOOC答案
- 法务岗位招聘笔试题与参考答案(某大型国企)2025年
- 2025年初级社会工作者综合能力全国考试题库(含答案)
- 2023大学-精密机械设计(庞振基黄其圣著)课后答案
- 《SMART原则培训》课件
评论
0/150
提交评论