c语言课程设计 宾馆管理信息系统.doc
【精品文档】如有侵权,请联系网站删除,仅供学习与交流c语言课程设计 宾馆管理信息系统.精品文档.数据结构体:文件名:Structs.h相应的实现:#include<stdio.h>#include<stdlib.h>#include<string.h>#define FLOORNUMBER 5#define ROOMNUMBER 10/房间类型枚举型 typedef enum room_typeSingle=1,Double=2,Luxury=3RoomType;/房间信息结构体 typedef struct room_infoint Num;RoomType Roomtype;char Local40;int Rflag;float Price;char Tag40;Room;/顾客信息结构体 typedef struct guest_infochar Name20;char ID20;char Sex;Guest;/客房信息结构体typedef struct guestandroom_infoint rNum;char gID20;char CheckinTime30;char CheckoutTime30;float debt;float discount;float pay;GAR;extern int GuestNum;float Income;int datin;int datbook;int datroom1,datroom2,datroom3;char Ttype310="Single","Double","Luxury"Room RoomsFLOORNUMBER*ROOMNUMBER;/房间信息数组 Guest GuestsFLOORNUMBER*ROOMNUMBER;/客户信息数组 GAR GARsFLOORNUMBER*ROOMNUMBER;/客房信息数组 1.初始化模块:对房间信息数组、客户信息数组、客房信息数组进行初始化,即从文件中读取相关信息 。文件名:Initialize.c函数名void Initialize();相应的函数实现:#include"Structs.h"void LoadRoomInfo()/房间信息初始化 FILE *fp;if(fp=fopen("RoomInfo.txt","r")=NULL)printf("Can't open the file of RoomInfo!n");exit(0);char temp58;fprintf(fp,"%s%s%s%s%s",temp0,temp1,temp2,temp3,temp4);int iCount;for(;iCount<FLOORNUMBER*ROOMNUMBER;iCount+)fprintf(fp,"%d%d%s%d%s",RoomsiCount.Num,RoomsiCount.Roomtype,RoomsiCount.Local,RoomsiCount.Rflag,RoomsiCount.Tag)Tag;printf("房间信息初始化成功.n");void LoadGuestInfo()/客户信息初始化 FILE *fp;if(fp=fopen("GuestInfo.txt","r")=NULL)printf("Can't open the file of GuestInfo!n");exit(0);char temp38;fprintf(fp,"%s%s%s",temp0,temp1,temp2);int iCount;for(;iCount<GuestNum;iCount+)fprintf(fp,"%s%s%c",GuestsiCount.Name,GuestsiCount.ID,GuestsiCount.Sex);printf("客户信息初始化成功.n");/初始化客房信息void LoadGARInfo()FILE *fp;if(fp=fopen("GARInfo.txt","r")=NULL)printf("Can't open the file of GARInfo!n");exit(0);char temp78;fprintf(fp,"%s%s%s%s%s%s%s",temp0,temp1,temp2,temp3,temp4,temp5,temp6);int iCount;for(;iCount<FLOORNUMBER*ROOMNUMBER;iCount+)fprintf(fp,"%d%s%s%s%f%f%f",GARsiCount.rNum,GARsiCount.gID,GARsiCount.CheckinTime,GARsiCount.CheckoutTime,GARsiCount.debt,GARsiCount.discount,GARsiCount.pay);printf("客房信息初始化成功.n");2.经营模块:对顾客的订房、入住、退房等手续进行办理,并同时完成相应后台数据的及时更新与统计。文件名:Run.c函数名:void Bookroom();void Checkin();void Checkout();相应的函数实现:#include"Structs.h"/订房功能模块int Findfree(int type)int i;for(i=0;i<FLOORNUMBER*ROOMNUMBER;i+)if(0=Roomsi.Rflag&&type=Roomsi.Roomtype)break;return i;void BookRoom()int broom;int freeroom;printf("订房功能:n");printf("请输入房间类型:1.标准单人间 2.标准双人间 3.豪华间n");scanf("%d",&broom);/查询是否有该类型空房间freeroom=Findfree(broom);if(freeroom<FLOORNUMBER*ROOMNUMBER)printf("请输入您的信息:n");printf("姓名:");scanf("%s",GuestsGuestNum+1.Name);printf("身份证ID:");scanf("%s",GuestsGuestNum+1.ID);printf("性别:");scanf("%c",GuestsGuestNum+1.Sex);printf("订房完成!n");/完成客户信息后,完成客房信息 strcpy(GARsfreeroom.gID,GuestsGuestNum+1.ID);GARsfreeroom.rNum=(freeroom/10+1)*100+freeroom%10);GuestNum+=1;elseprintf("该类型房间已无空余!n");/入住功能void CheckIn()int choose=0;int iCount;int sign=0;char tID20; printf("你预定房间了吗?1.已预订 2.未预定n");doprintf("请选择:");scanf("%d",&choose);while(choose!=1&&choose!=2);if(1=choose)printf("请输入你的身份证号:");scanf("%s",tID); for(iCount=0;iCount<FLOORNUMBER*ROOMNUMBER;iCount+)if(strcmp(GARsiCount.gID,tID)=0)printf("请输入入住时间:");scanf("%s",GARsiCount.CheckinTime);sign=1;break;datbook+;elseprintf("请输入您要的房间类型:1.标准单人间 2.标准双人间 3.豪华间n");scanf("%d",&choose);int freeroom=Findfree(choose);if(freeroom<FLOORNUMBER*ROOMNUMBER)printf("请输入客户信息:");printf("姓名:");scanf("%s",GuestsGuestNum+1.Name);printf("身份证ID:"); scanf("%s",GuestsGuestNum+1.ID);printf("性别:");scanf("%c",&GuestsGuestNum+1.Sex);strcpy(GARsfreeroom.gID,GuestsGuestNum+1.ID);GARsfreeroom.rNum=(freeroom/10+1)*100+freeroom*10);sign=1;elseprintf("该类型的房间无空余!n");if(1=sign)printf("入住成功!n");/退房功能模块void CheckOut()int rNum;int count;int count2;int day=0;printf("请输入你入住的房间号:");scanf("%d",&rNum);for(count=0;count<FLOORNUMBER*ROOMNUMBER;count+)if(rNum=GARscount.rNum)printf("请输入退房时间:");scanf("%s",GARscount.CheckoutTime);printf("%d%10s%15s%10s%10sn","房间号","类型","位置","单价","备注");printf("%d%10s%15s%10.1f%10sn",Roomscount.Num,TtypeRoomscount.Roomtype,Roomscount.Local,Roomscount.Price,Roomscount.Tag);printf("%10s%10s%10s%10s%10sn","顾客","ID","性别","入住时间","退房时间");for(count2=0;count2<GuestNum;count2+)if(Guestscount2.ID=GARscount.gID)break;printf("%10s%20s%5c%30s%30sn",Guestscount2.Name,Guestscount2.ID,Guestscount2.Sex,GARscount.CheckinTime,GARscount.CheckoutTime);printf("输入居住天数:");scanf("%d",&day);printf("折扣:");scanf("%f",&GARscount.discount);printf("账单:n");GARscount.debt=Roomscount.Price*day;GARscount.pay=GARscount.debt*GARscount.discount;printf("应付: 折扣: 实际付:");printf("%10.1f%10.1f%10.1fn",GARscount.debt,GARscount.discount,GARscount.pay); printf("谢谢您的光临!n");Income+=pay;GuestNum-;汪峰:3.管理模块:对存储的客户信息和房间信息进行修改更正。文件名:Manage.c函数名:void Correct();void Delectable();相应的函数实现:#include"Structs.h"/修改信息int m_menu()int choose=0;printf("管理菜单:n");printf("1.房间信息n2.顾客信息n");doprintf("选择:");scanf("%d",&choose);while(choose!=1&&choose!=2);return choose;void Correct()/修改功能函数 /此功能用于修改房间信息 int choose;int ch1,ch2;int cNum;char cID20;char cName20;printf("修改模块:n");choose=m_menu();switch(choose)case 1:printf("输入需更改信息的房间号:");scanf("%d",&cNum);printf("更改项:1.类型 2.单价 3.备注n");doprintf("选择:");scanf("%d",ch1);while(ch1<1|ch1>3);if(ch1=1)printf("类型:1.标准单人间 2.标准双人间 3.豪华间n");doprintf("选择:");scanf("%d",ch2);while(ch2<1|ch2>3);RoomscNum.Roomtype=ch2;printf("修改完成!n");/添加一个shou函数else if(ch1=2)printf("输入单价:");scanf("%f",&RoomscNum.Price);printf("修改完成!n");else if(ch1=3)printf("输入修改的备注:n");scanf("%s",RoomscNum.Tag);printf("修改完成!n");break;case 2:printf("输入需更改信息客户ID:");scanf("%s",cID);for(temp=0;temp<GuestNum;temp+)if(strcmp(cID,Gueststemp.ID)Name=0) break;printf("输入更改后的姓名:");scanf("%s",cName);strcpy(Gueststemp.Name,cName);break;/删除功能模块 void Delect()int choose;int temp;int cNum;char cID20;printf("删除功能:n");choose=m_menu();switch(choose)case 1: printf("输入需更删除的房间号:");scanf("%d",&cNum);RoomscNum.Num=0;RoomscNum.Roomtype=-1;RoomscNum.Local=""RoomscNum.Tag=""break;case 2:printf("输入需更删除的顾客:");scanf("%s",cID);for(temp=0;temp<GuestNum;temp+)if(strcmp(cID,Gueststemp.ID)=0)break;Gueststemp.Name=""Gueststemp.ID=""Gueststemp.Sex=""break;4.查询模块:对相应的信息进行查找,如单个房间信息、单个客户信息、所有房间信息。文件名:Search.c函数名:void Search();相应的函数实现:#include"Structs.h" /查询功能模块int S_menu()/搜索功能主菜单 int ch;doprintf("1.单个房间信息n");printf("2.单个客户信息n");printf("3.所有入住客户信息n");printf("选择:");scanf("%d",&ch);while(ch<1|ch>3);return ch;void search()int choose;/选择变量 int snum;/临时房间变量 char sguest20;/临时顾客姓名变量 int temp,t1;/临时中间变量 printf("查询功能:n");choose=S_menu();switch(choose)case 1:printf("输入所要查询的房间号:n");scanf("%d",&snum);printf("Loadingn");for(temp=0;temp<FLOORNUMBER*ROOMNUMBER;temp+)if(Roomstemp.Num=snum)break;if(temp<FLOORNUMBER*ROOMNUMBER)printf("%d,%s,%s,%s,%f,%sn",Roomstemp.Num,TtypeRoomstemp.Roomtype,Roomstemp.Local,Roomstemp.Price,Roomstemp.Tag);elseprintf("输入的房间号有误n");break;case 2:printf("输入所要查询的顾客姓名:n");scanf("%s",sguest);printf("Loadingn");for(temp=0;temp<GuestNum;temp+)if(strcmp(Gueststemp.Name,sguest)=0)break;if(temp<GuestNum)printf("%s,%s,%cn",Gueststemp.Name,Gueststemp.ID,Gueststemp.Sex);elseprintf("输入的顾客姓名有误n");break;case 3:for(temp=0;temp<FLOORNUMBER*ROOMNUMBER;temp+)printf("%d,%s",Roomstemp.Num,TtypeRoomstemp.Roomtype);if(Roomstemp.Rflag=1|Roomstemp.Rflag=2)for(t1=0;t1<FLOORNUMBER*ROOMNUMBER;t1+)if(strcmp(GARstemp.gID,Gueststemp.ID)=0) break;printf("%s,%s,%s,%sn",Guestst1.Name,GARstemp.gID,GARstemp.CheckinTime,GARstemp.CheckoutTime);else if(Roomstemp.Rflag=0)printf("n");break;5.统计分析模块:对宾馆的经营状况进行统计分析 ,同时做出简单的反馈信息。文件名:Analysis.c函数名:void Analysis();相应的函数实现:#include"Structs.h"/统计分析功能模块void Analysis()float per;per=GuestNum/(FLOORNUMBER*ROOMNUMBER);printf("统计分析模块n");printf("1.入住率:%8.2f%n",per);printf("2.总收入:%8.2f%n",Income);printf("3.订房与直接入住的比较:");printf("%d:%dn",datbook,datin);printf("入住房间类型的统计:");printf("标准单人间:%d; 标准双人间:%d; 豪华间:%dn",datroom1,datroom2,datroom3);if(per<0.6)printf("宾馆的经营状况急需改善!n");else if(per<0.75)printf("宾馆的经营状况一般!n");elseprintf("宾馆的经营状况较好!n");printf("宾馆经营,要好好加油啊!");