1、汇报正文一、题目要求用户信息包含身份证号、姓名、性别、年纪、房间号。试设计一客房管理系统,使之能提供以下功效:(1) 系统以菜单方法工作(2) 用户信息录入功效(用户信息用文件保留)(3) 用户信息统计功效(4) 用户信息查询功效,查询方法(5) 用户信息修改功效(可选项) 提醒 建立用户信息结构体,结构体组员包含身份证号、姓名、性别、年纪、房间号 二、需求分析依据题目要求,要求对用户信息进行输入、输出等操作;在程序中需要浏览用户信息,应提供显示、统计、查询、修改等操作;另外还应提供键盘式选择菜单实现功效选择。三、总体设计依据需求分析,能够对这个系统设计分为以下多个模块:用户信息管理系统数据输
2、入数据统计数据查询数据修改数据删除系统功效模块图四、具体设计1、主函数部分:主函数通常设计得比较简练,只提供输入,处理和输出部分函数调用。其中各功效模块用菜单方法选择。步骤图:显示各功效选项依据 n值调用各功效模块函数NY输入n ,判定n 是否是0-5主函数步骤图main() /*主函数*/printf(nnntt酒店管理系统);printf(nnntttPress any key to continue.);printf(nnnnnnnnnnnntttttttt-By黄李n);getch();menu();void regist() /*注册函数*/int n,m,i,j;printf(tH
3、ow many new customs?t);scanf(%d,&n);printf(tHow many rooms they want? );scanf(%d,&m); for(i=r;ir+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); roomi.sign=1; for(j=p;jp+n;j+) puts(ntName:t);scanf(%s,roomi.client_listj.name
4、); 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_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)
5、;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);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、&n);if(n5) 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 age; char ID_ca
7、rd20; /*居民身份证*/ 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();void load_room()
8、;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 new customs?t);scanf(%d
9、,&n);printf(tHow many rooms they want? );scanf(%d,&m);for(i=r;ir+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); roomi.sign=1; for(j=p;jp+n;j+) puts(ntName:t);scanf(%s,roomi.client_listj.name); puts(ntSex(1 for men | 0 for
10、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.client_listj.year); puts(ntMonth:t);scanf(%d,&roomi.client_listj.month); puts(ntDate:t);scanf(%d,&roomi.client_listj.da
11、te); 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(tt*n);printf(ttPlease choice your number(1-3): bb);scan
12、f(%d,&n);if(n3) 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 the month you want to statistics:);scanf(%d,&n);load_room();for(i=0;ir;i+) for(j=0;jp;j+) if(roomi.client_listj.month
13、=n) s=s+1;printf(There are %d customer this month,s);puts(nnWhat you want to do?n);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;jp;j+) if(roomj.sign=1) s+=1;printf(There are %d rooms in use,
14、s);puts(nnWhat you want to 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_listj.name);printf(nsex:%dn,roomi.client_listj.sex);printf(nage:%dn,roomi.client_listj.age);puts(nID_card:
15、);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.tel);printf(nPrice:%dn,roomi.price);(3)查找模块是否找到用户统计输入一整型数值提醒没有找到YN查找模块1,2,还
16、是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 n);puts(tt3).MENU();puts(tt*n);printf(ttPlease choice your number(1-3): bb);scanf(%d,&n);if(n3) m=1; getchar(); else
17、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;printf(Please input the namen);scanf(%s,s);load_room();for(i=0;ir;i+) for(j=0;jp;j+)if(strcmp(roomi.client_listj.name,s)=0) w=1,m=i,n=j;if(w=1)printf_p(m,
18、n);else printf(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 want to search);printf(nYear:); scanf(%d,&a
19、);printf(nMonth:); scanf(%d,&b);printf(nDate:); scanf(%d,&c);load_room();for(i=0;ip;i+)for(j=0;jr;j+) if(roomi.client_listj.date=c)&(roomi.client_listj.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
20、).backn);scanf(%d,&l); switch(l)case 1:search_day();break; case 2:search(); (4)修改模块需求分析 该模块功效是插入用户统计信息而且不能覆盖原有用户信息。步骤图 插入模块调用加载函数让用户输入要插入用户信息个数调用整条信息输入函数用户作出选择,输入1or21还是22返回主菜单1 浏览全部修改模块步骤图程序:void modify() /* 修改函数 */int n,m;doputs(tt*MENU*n);puts(tttt1).modify one peoplen);puts(tttt2).modify one day
21、n);puts(tttt3).MENU();puts(tt*n);printf(ttPlease choice your number(1-3): bb);scanf(%d,&n);if(n3) 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);sca
22、nf(%s,s);load_room();for(i=0;ir;i+) for(j=0;jp;j+) if(strcmp(roomi.client_listj.name,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,&l); switch(l) case 1:modify_one();break; c
23、ase 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);printf(Please choice your number(1-10): bb);scanf(%d,&q);switch(q) case 1:
24、 printf(Please input new namen);scanf(%s,s);strcpy(roomi.client_listj.name,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.age=a;break; case 4: printf(Please input new ID_cardn);sca
25、nf(%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; case6: printf(Please input the new monthn); scanf(%d,&a);roomi.client_listj.month=a;break; case7: printf(Please input the new daten);scanf(%d,&a);roomi.client_list
26、j.date=a;break; case8: printf(Please input the new room_IDn);scanf(%d,&a);roomi.room_ID=a;break; case9: 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);roomi.price=a;break; case 11 : modify(); void modify_day() /*修改某
27、日信息*/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_room();for(i=0;ip;i+) for(j=0;jr;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)
28、;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)保留函数 save()void save() /*保留函数*/FILE*fp;int i,j;if(fp=fopen(room.txt,w)=NULL)printf(nCannot open filen); retur
29、n NULL;for(i=0;ir;i+) for(j=0;jnn 1).number 2).name 3).cancel and back);printf(Which you needed?: bb);scanf(%d,&c);if(c3|c3|c1);doswitch(c)case 1:no_input(i,n);break;case 2:printf(name:);scanf(%s,staffi.name);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,&w1);if(w1=1)save(n);while(w1=2);return(w1);
©2010-2024 宁波自信网络信息技术有限公司 版权所有
客服电话:4008-655-100 投诉/维权电话:4009-655-100