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

下载本文档

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

文档简介

1、报告正文、题目要求客户信息包括身份证号、性别、年龄、房间号。试设计一客房管理系统,使之 能提供以下功能:1系统以菜单方式工作2客户信息录入功能客户信息用文件保存3客户信息统计功能4客户信息查询功能,查询方式5客户信息修改功能可选项提示建立客户信息结构体,结构体成员包括身份证号、性别、年龄、房间号、需求分析根据题目要求,要求对客户信息进行输入、输出等操作;在程序中需要浏览客户 的信息,应提供显示、统计、查询、修改等操作;另外还应提供键盘式选择菜单实现 功能选择。三、总体设计根据需求分析,可以对这个系统的设计分为以下几个模块:数据查询数据修改数据删除系统功能模块图四、详细设计1、主函数局部:主函数

2、一般设计得比拟简洁,只提供输入,处理和输出局部的函数调用。其中各 功能模块用菜单方式选择。流程图:显示各功能选项1FN输入n ,判t断 n是否是0-5Y根据n的值调用各功能模块函数主函数流程图main()/* 主函数 */、竹、prin店管理系printf("nnntttPress any key to continue.");printf("nnnnnnnnnnnntttttttt-By黄李 n");getch();menu();void regist()/* 注册函数 */int n,m,i,j;printf("tHow many new

3、customs?t");scanf("%d",&n);printf("tHow many rooms they want?");scanf("%d",&m);for(i=r;i< r+m;i+)puts("ntRoomD:t");sca nf("%d",&roomi.roo mD); puts("ntTel:t");sca nf("%s",roomi.tel);puts("ntPrice:t");

4、sca nf("%d",&roomi.price);oe>es c+dHd -lu+H宀I 宀 lepms=lc2o=Eooos-=p&=)ueo"(9ecmur)slnd _(£UOEms=lc2o=Eooos-=p&=)4ueo"(=y£uol/nvJr)slnd oe Mms=lc2o=Eooos-=p&=)ueo"(Neekwr)slnd eeold§s=lc2o. UEOO-=s&=)ueo"(老 peolcl 三urKnd 6ems=lc2o=Eo

5、oos-=p&=)ueo"(9&6swr)slnd _(x sms=JU2o=Eooos-=p&=)4ueo"(N(u®EOM 0 - uE O4 L)x slwr)slnd Eeums=llu2o=Eoo-=s&=)4ueo"(9/EeNAUr)slnd(+ru+dvrdHD04(ur*(U)II9'?S _(LHHM¥壬X ohm SO5oelpa)q lhm (9AU-VU)七 eos-=p&=)ueos (gLxeqEnu noA oolp se -dsrmu 一d*Lur)slnd(三-

6、一 七x山 厂5= ©POIAI (u三 lpes (5=s。匸 SQSS (u三 运6ML CXI co 寸 insurKnd surKnd surKnd surKnd surKnd(uwr*n N 山 l/l*luuu=)slndopMu lu? * * ()nuE p一0>case 1:regist();break;case 2:stat();break;case 3:search();break;case 4:modify();break;case 5:exit(0);注: menu 函数能提供菜单方式选择功能,可以根据用户需要进入到所想要的操作模 块中,此外把 men

7、u 函数独立出来,可以方便随时对它进行调用,容易返回到系统界 面。并用结构体来存放客户信息:struct clientchar name20;int sex;int age;char ID_card20; /* 居民身份证 */int year;int month;int date;/*住店时间 */;struct hotelint room_ID; /*房间号 */char tel15;int price;/*住房单价 */int sign;struct client client_listM;/* 实现两个结构体的嵌套 */roomN;int r=0;p=0;/*r,p 为全局变量 */v

8、oid menu();void search_one();void search_day();void modify();void modify_one();void load_room();void modify_day();void modify_s(i nt j,i nt i);void save();void search();void stat_u();void stat_o();void regist();void stat();2、各功能模块函数局部:1输入模块需求分析对信息进行输入流程图:程序void regist()/* 注册函数 */int n,m,i,j;printf(&

9、quot;tHow many new customs?t");scanf("%d",&n);prin tf("tHow many rooms they wa nt?");sca nf("%d",&m);for(i=r;i<r+m;i+)puts("n'tRoom_I D:t");sca nf("%d",&roomi.roo m_I D);puts("ntTel:t");sca nf("%s",roomi.te

10、l);puts("ntPrice:t");sca nf("%d",&roomi.price);电 roomi.sig n=1;for(j=p;j<p+n;j+)puts("n tName:t");sca nf("%s",roomi.clie nt_listj. name);puts("ntSex(1 for men | 0 for wome n):t");sca nf("%d", &roomi.clie nt_listj.sex);puts("

11、n tAge:t");sca nf("%d",&roomi.clie nt_listj.age);puts("ntlD_card:t");sca nf("%s",roomi.clie nt_listj .I D_card);puts("ntYear:t");sca nf("%d",&roomi.clie nt_listj.year);puts("ntMo nth:t");sca nf("%d", &roomi.clie n

12、t_listj.mo nth);puts("ntDate:t");sca nf("%d",&roomi.clie nt_listj.date);r=r+m;p=p+n; save(); menu();2统计模块统计模块流程图/* 统计函数 */程序void stat()int n,m; doputs("tt*MENU* puts("tttt1).Statistics one monthn");puts("tttt2).Statistics using roomn");puts("tttt

13、3).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() /* 统计人数 */int j,i,n,l;int s=0;p

14、uts("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"); puts("1).Statis

15、tics 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 do?n"); puts("1)

16、.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",roomi.client_listj

17、.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",roomi.room_ID);

18、 printf("nTel:%sn",roomi.tel);printf("nPrice:%dn",roomi.price); 3查找模块查找模块查找模块流程图*查找函数*程序:void n,m;do puts("nntt*MENU*n"); puts("tt1).Search some one had erev lived heren");puts("tt2).Search someday n");puts("tt3).MENU()"); puts(&

19、quot;tt* n") prin tf("ttPlease choice your number(1-3): bb");scan f("%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 search_one() /* 查找个人 */int i,j,w=0,l,m,n;char s20;p

20、rintf("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 do you want to do?n");puts("1).

21、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("%d",&a);printf("

22、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.cli ent_listj.year=a) w=1,m=i,n=j,printf_p(m,n);if(w=O)prin tf(

23、"NO record this dayn );puts("What you want to do?n);puts("1).search agai nt2).back n");scan f("%d",&l);switch(l)case 1:search_day();break;case 2:search();4修改模块需求分析该模块的功能是插入客户记录信息并且不能覆盖原有客户信息流程图修改模块流程图程序:void modify() /* 修改函数 */ int n,m;doputs("tt*MENU* puts(&qu

24、ot;tttt1).modify one peoplen");puts("tttt2).modify one dayn");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:mod

25、ify_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); 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) print

26、f_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",&l);switch(l)case 1:modify_one();break;case 2:modify();void modify_s(int i,int j)/* 修改执行项 */int a,q;char s20,b

27、15; printf("nChoice the title you want to modifyn");7).dateputs("1).Name 2).sex 3).age 4)ID_card 5).year 6).month 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("Pleas

28、e input new namen");scanf("%s",s);strcpy(roomi.client_,s);break;case 2:printf("Please input new sexn");scanf("%d",&a);roomi.client_listj.sex=a;break;case 3:printf("Please input the new agen");scanf("%d",&a);roomi.client_listj.a

29、ge=a;break;case 4:printf("Please input new ID_cardn");scanf("%s",s);strcpy(roomi.client_listj.ID_card,s);break;case5:printf("Please input new yearn");scanf("%d",&a);roomi.client_listj.year=a;break;monthn");case6: printf("Please input the new scan

30、f("%d",&a);roomi.client_listj.month=a;break;case7:printf("Please input the new daten");scanf("%d",&a);roomi.client_listj.date=a;break;case8:printf("Please input the new room_IDn");scanf("%d",&a);roomi.room_ID=a;break;teln");case9: pr

31、intf("Please input the newscanf("%s",b);strcpy(roomi.tel,b);break;case 10:printf("Please input 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"

32、); puts("nYear:");scanf("%d",&a); puts("nMonth:");scanf("%d",&b); puts("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)&&(room

33、i.cli ent_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("1).modify againt2).backn");scanf("%d",&l);switch(l)case 1:modify_day();break;case 2:menu(); 3、公共函数局部:1保存

34、函数 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+)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.p rice,roomi.sign,roomi.clie

35、nt_,roomi.client_listj.sex,roomi.client_listj.age,room i.client_listj.ID_card,roomi.client_listj.year,roomi.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+)for(j=0;!feof(fp);j+)fscanf(fp,"%d,%s,%d,%d,%s,%d,%d,%s,%d,%d,%d",&roomi.r

温馨提示

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

评论

0/150

提交评论