【C语言实战应用】客房管理系统报告_第1页
【C语言实战应用】客房管理系统报告_第2页
【C语言实战应用】客房管理系统报告_第3页
【C语言实战应用】客房管理系统报告_第4页
【C语言实战应用】客房管理系统报告_第5页
已阅读5页,还剩18页未读 继续免费阅读

下载本文档

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

文档简介

C语言实践应用客房管理系统一总体设计本程序包含用户登记、统计、查询、修改等四大功能。其中用户登记功能包含用户姓名、性别、年龄、身份证、入住年份、入住月份、入住日期、房间号、房间电话及房间价格;统计功能包含按性别统计、按年龄统计及按入住时间(年月日)统计;查询功能包含按房间号查询、按姓名查询及按性别查询;修改功能包含性别修改、年龄修改、入住年份修改、入住月份修改及入住日期修改。下面以流程图的形式展示本程序设计思路: 开始 输出 1.登记2.统计3.查询4.修改5.退出 输入 n=1选择用户登记功能 输入用户信息及客房信息 系统自动分配房间号 是否继续输入用户信息输入k k=1? 是 否 输出 1.登记2.统计3.查询4.修改5.退出 输入n 功能菜单选择 n=2 n=3 n=4 n=5 退出输入姓名输出1.按房间号2.按姓名3. 按性别查询输出1.按性别统计2.按年龄统计3.按入住日期统计 结束输出用户信息 输出1.性别2.年龄3.年份4.月份5.日期输入i输入i 输入a i=1 i=2 i=3 i=1 i=2 i=3 输入性别输入姓名 输入房间号输出各日期段人数 输出各年龄段人数输出男女性别人数 输入k 输入日期输入月份输入年份输入年龄输入性别 a=1 a=2 a=3 a=4 a=5输入kk=1 k=1?k=1 k=1? k=1 k=1? 是 是 是 否 否 否二设计模块一个较大的C语言程序不外乎由多个函数组成,本程序也并不例外。现就本程序中涉及的各个函数的代码和功能分别进行说明。1.main函数void main()ini();menu();本函数用于调用ini函数和menu函数(介绍见下文)。2.ini函数void ini()int i=0;for(;i100;i+)Roomi.sign=false;Roomi.Room_ID=i;本函数功能为先定义所有的房间为空并依次定义各个房间的序号。3.menu函数void menu()int n,k;doprintf(1.登记n);printf(2.统计n);printf(3.查询n);printf(4.修改n);printf(5.退出n);printf(Choice your number(1-5):);scanf(%d,&n);if(n5)k=1;puts(Please enter againn);else k=0;while(k=1);switch(n)case 1:dengji();break;case 2:tongji();break;case 3:chaxun();break;case 4:xiugai();break; case 5:exit(0);本函数的功能为输出功能菜单选项,其中包括登记、统计、查询、修改及退出。系统根据输入的选项调用相应的功能函数。4.dengji函数void dengji()int k=1,i=0;while(k)printf(Please enter the Name:);scanf(%s,Roomi.Client_list.Name);printf( Please enter the Sex, Men 1, Women 2 :);scanf(%d,&Roomi.Client_list.Sex);printf(Please enter the Age:); scanf(%d,&Roomi.Client_list.Age);printf(Please enter the ID_card:);scanf(%d,&Roomi.Client_list.ID_card);printf(Please enter the year:);scanf(%d,&Roomi.Client_list.year);printf(Please enter the month:);scanf(%d,&Roomi.Client_list.month);printf(Please enter the date:);scanf(%d,&Roomi.Client_list.date);printf(Please enter the Tel:);scanf(%d,&Roomi.Tel);printf(Please enter the Price:);scanf(%d,&Roomi.Price);Roomi.sign=true;printf(The Room_ID is:%dn,Roomi.Room_ID);i+;printf(Do you want to continue?, Yes 1, No 0: );scanf(%d,&k);if(k!=1&k!=0)printf(You have entered the wrong number, please enter againn);printf(Do you want to continue?, Yes 1, No 0: );scanf(%d,&k);menu();本函数的功能为登记用户及房间信息,包括姓名、性别、年龄、身份证、年份、月份、日期、房间电话及房间价格。系统依次分配房间号并定义此房间为非空。管理员可根据具体情况登记相应用户人数的信息。在此申明由于本程序并未将用户信息存入磁盘,因此务必先登记用户信息再执行功能菜单中的其他功能。5.tongji函数void tongji()int i;printf(1.According to the sex 2.According to the age 3.According to the time:);scanf(%d,&i);if(i!=1&i!=2&i!=3)printf(You have entered the wrong number, please enter againn);tongji();switch(i)case 1: xingbie();break;case 2: nianling();break;case 3: shijian();break; 本函数的功能为输出统计功能菜单选项,包括根据按性别统计、根据年龄统计及根据入住时间统计。系统根据输入的选项执行相应的函数(介绍见下文)。6.xingbie函数void xingbie()int i,a=0,b=0,k=0;for(i=0;Roomi.sign;+i)switch(Roomi.Client_list.Sex)case 1:a+;break;case 2:b+;break;printf(Men:%dn Women:%dn,a,b);printf(Do you want to continue? Yes 1, No 0: );scanf(%d,&k);if(k!=1&k!=0)printf(You have entered the wrong number, please enter againn);printf(Do you want to continue?, Yes 1, No 0: );scanf(%d,&k);if(k) tongji();else menu(); 本函数的功能为分别输出用户中男女性别的人数。7.nianling函数void nianling()int i,a=0,b=0,c=0,k=0;for(i=0;Roomi.sign;i+)switch(Roomi.Client_list.Age/20)case 0:a+;break;case 1:b+;break;default:c+;printf(Age20:%dn20=Age=40:%dn,a,b,c);printf(Do you want to continue? Yes 1, No 0: );scanf(%d,&k);if(k!=1&k!=0)printf(You have entered the wrong number, please enter againn);printf(Do you want to continue?, Yes 1, No 0: );scanf(%d,&k);if(k) tongji();else menu(); 本函数的功能为分别输出用户中年龄在20岁以下、20至40岁及40岁以上的人数。8.shijian函数void shijian()int i,a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,j=0,k=0;for(i=0;Roomi.sign;i+)switch(Roomi.Client_list.year)case 2009:a+;break;case 2010:b+;break;for(i=0;Roomi.sign;i+)if(Roomi.Client_list.date=10) c+;else if(Roomi.Client_list.date10) d+;else e+;for(i=0;Roomi.sign;i+)if(Roomi.Client_list.month=3) f+;else if(Roomi.Client_list.month3) g+;else if(Roomi.Client_list.month6) h+;else j+;printf(2009:%dn 2010:%dn month=3:%dn3month=6:%dn6month=9:%dn9month=12:%dn date=10:%dn10date=20:%dn20date30:%dn,a,b,f,g,h,j,c,d,e);printf(Do you want to continue? Yes 1, No 0:);scanf(%d,&k);if(k!=1&k!=0)printf(You have entered the wrong number, please enter againn);printf(Do you want to continue?, Yes 1, No 0: );scanf(%d,&k);if(k) tongji();else menu(); 本函数的功能为分别输出用户中入住年份在2009年及2010年的人数,入住月份在3月以下、3月至6月、6月至9月、9月至12月份的人数及入住日期在10日以下、10日至20日、20日以上的人数。9.shuchu函数void shuchu(int i)printf(Name:%s Sex: %d Age: %d ID_card: %d Time: %d-%d-%d Room_ID: %d Tel: %d Price: %dn,Roomi.Client_list.Name,Roomi.Client_list.Sex,Roomi.Client_list.Age,Roomi.Client_list.ID_card,Roomi.Client_list.year,Roomi.Client_list.month,Roomi.Client_list.date,Roomi.Room_ID,Roomi.Tel,Roomi.Price);本函数的功能为输出相应用户及所在房间信息,包括姓名、性别、年龄、身份证、入住时间(年月日)、房间号、房间电话及房间价格。10.chaxunvoid chaxun()int i;printf(1.According to the Room_ID 2.According to the name 3.According to the sex:);scanf(%d,&i);if(i!=1&i!=2&i!=3)printf(You have entered the wrong number, please enter againn);chaxun();switch(i)case 1: Room_ID();break;case 2: name();break;case 3: Sex();break;本函数的功能为输出查询功能菜单选项,包括根据房间号查询、根据姓名查询及根据性别查询。系统根据输入的选项执行相应的函数(介绍见下文)。11.Room_ID函数void Room_ID()int i=0,a,k;printf(Please enter the Room_ID:);scanf(%d,&a);for(;i100;+i)if(Roomi.Room_ID=a)if(Roomi.sign=true) shuchu(i);else printf(There is no person in the roomn);break;printf(Do you want to continue? Yes 1, No 0:);scanf(%d,&k);if(k!=1&k!=0)printf(You have entered the wrong number, please enter againn);printf(Do you want to continue?, Yes 1, No 0: );scanf(%d,&k);if(k) chaxun();else menu();本函数的功能为系统根据输入的房间号调出该房间中的用户信息及房间信息。12.name函数void name()int i=0,k,l=0;char str20;printf(Please enter the Name:);scanf(%s,str);for(;Roomi.sign;i+)if(strcmp(str,Roomi.Client_list.Name)=0) shuchu(i);l=1;if(!l) printf(There is not the personn);printf(Do you want to continue? Yes 1, No 0:);scanf(%d,&k);if(k!=1&k!=0)printf(You have entered the wrong number, please enter againn);printf(Do you want to continue?, Yes 1, No 0: );scanf(%d,&k);if(k) chaxun();else menu();本函数的功能为系统根据输入的姓名调出该用户的信息及所在房间信息,若无此用户则输出查无此人。13.Sex函数void Sex()int i=0,k,a,l=0; printf(Please enter the sex, Men 1, Women 2:);scanf(%d,&a);for(;Roomi.sign;+i)if(Roomi.Client_list.Sex=a) shuchu(i);l=1;if(!l) printf(There is no the sexn);printf(Do you want to continue? Yes 1, No 0:);scanf(%d,&k);if(k) chaxun();else menu();本函数的功能为系统根据输入的性别调出该性别的用户信息及所在房间信息。14.xiugai函数void xiugai()int i=0,k,a,l=0;char str20;printf(Please enter the name:);scanf(%s,str);for(;Roomi.sign;+i) if(strcmp(str,Roomi.Client_list.Name)=0) l+;shuchu(i);break;if(!l)printf(You have entered the wrong name, please enter againn);xiugai();printf(What you want to corret is as follow:n1.Sex 2.Age 3.year 4.month 5.date:);scanf(%d,&a);if(a!=1&a!=2&a!=3&a!=4&a!=5)printf(You have entered the wrong number, please enter againn);printf(What you want to corret is as follow:n1.Sex 2.Age 3.year 4.month 5.date:);scanf(%d,&a);switch(a)case 1:printf(Please enter the sex:);scanf(%d,&Roomi.Client_list.Sex);break;case 2:printf(Please enter the age:);scanf(%d,&Roomi.Client_list.Age);break;case 3:printf(Please enter the year:);scanf(%d,&Roomi.Client_list.year);break;case 4:printf(Please enter the month:);scanf(%d,&Roomi.Client_list.month);break;default:printf(Please enter the date:);scanf(%d,&Roomi.Client_list.date);printf(Do you want to continue? Yes 1, No 0:);scanf(%d,&k);if(k!=1&k!=0)printf(You have entered the wrong number, please enter againn);printf(Do you want to continue?, Yes 1, No 0: );scanf(%d,&k);if(k) xiugai();else menu();本函数的功能为系统根据输入的姓名调出该用户及所在房间信息,同时输出修改功能菜单选项,包括修改性别、修改年龄、修改入住年份、修改月份及修改日期。系统根据输入的选项修改用户相应的信息。三.结束语C语言是一门计算机语言,如同其他计算机语言甚至日常交际中常说的外语一样需要不断的练习和实践才能逐渐掌握并熟练运用。尤其是对于带有创造性的编写一个较大C语言程序时更能凸现出这一点。由于本人学习该语言理论知识时间仓促加之课下没有进行大量的程序编写练习,因此在编写及调试本程序过程中难免遇到了诸多问题。现就出现的这些问题及解决办法作简要分析。1.设计思路起初对于本程序的思路都是一片空白,对于题目中要求实现的用户登记、统计、查询、修改功能不知

温馨提示

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

评论

0/150

提交评论