C语言 宾馆客房管理系统.doc
C语言 宾馆客房管理系统!? 宾馆客房管理系统 宾馆的客房销售是宾馆的主要利润来源。要求针对客房的属性,如房号、房价(只要分为三个档次价格即可)、入住情况、维护状况进行分析编程,要求实现若干功能,如:能够随时地通过程序查看每间客房的状态,查讯各种价位的空房数量和具体房号、查讯各种价位客房的入住数量和房号,当前正在维修的所有客房房号,随时统计当月的销售总收入,在文件中记录每个房间入住和退房情况及单价、毛利收入,根据上个月的文件记录,次月可以统计上个月的销售总收入等等。该管理系统运行时是一个循环式的菜单选项,能依据选项选择各种功能。并能依据需求,将结果打印在屏幕或打印到文件中。 #include <stdio.h> #include <stdlib.h>#include <string.h>/*void initial_room(); /初始化80个房间信息void welcome(); /验证用户登陆,登陆成功显示欢迎信息void enter();void book_room();void check_in();void check_out();void inquire();int i=0;/*struct Room int number; int dank; int price; int state; ;struct Customer char name10,ID19; int room_number; int prepaid; int change; int day;void set_name(struct Customer *cs, char *n) strcpy(cs->name,n);void set_ID(struct Customer *cs, char *p) strcpy(cs->ID,p);void set_room_number(struct Customer *cs, int n) cs->room_number=n;void set_day(struct Customer *cs, int d) cs->day=d;void set_prepaid(struct Customer *cs, int p) cs->prepaid=p;char *get_name(struct Customer *cs) return cs->name;char *get_ID(struct Customer *cs) return cs->ID;int get_room_number(struct Customer *cs) return cs->room_number;int get_day(struct Customer *cs) return cs->day;int get_prepaid(struct Customer *cs) return cs->prepaid;/*struct Room room80;struct Customer *customer80;void CCustomer(struct Customer *cs) printf("请您输入顾客的姓名n"); scanf("%s",&cs->name); printf("请您输入顾客的身份证号码n"); scanf("%s",&cs->ID); cs->prepaid = cs->change = cs->day = 0;void FCustomer() printf("该顾客退房成功!");int main(void) /程序入口从这里开始运行 char choice='1' initial_room(); /初始化80个房间的信息,分四个等级 welcome(); /验证用户登陆,登陆成功显示欢迎信息 while(choice='1') enter(); /根据用户的选择执行不同的功能 printf("n"); printf("继续使用本系统请按"1",退出请按"2"! "); fflush(stdin); scanf("%c",&choice); printf("n"); return 0;/系统登陆界面*void welcome() /验证用户登陆,登陆成功显示欢迎信息 char name4,code7; printf("请输入用户名和密码(以空格隔开):n"); scanf("%s%s",&name,&code); while(strcmp(name,"000")!=0)|(strcmp(code,"666666")!=0) printf("用户名或密码输入有误,请重新输入!n"); scanf("%s%s",&name,&code); printf("n"); printf("n"); printf(" *n"); printf(" 欢迎使用宾馆客房管理系统! n"); printf(" *n"); printf("n");/系统入口*void enter() int kind_of_service; printf("请选择服务类别:订房、入住、退房还是查询? n"); printf(" 1->定房 2->入住 3->退房 4->查询: "); scanf("%d",&kind_of_service); if(kind_of_service>4) | (kind_of_service<1) printf("您的输入有误,请重试!n"); scanf("%d",&kind_of_service); else switch(kind_of_service) case 1: book_room(); break; case 2: check_in(); break; case 3: check_out(); break; case 4: inquire(); break; /订房实现*void book_room() int room_standard,day; customeri = (struct Customer*)malloc(sizeof(struct Customer); CCustomer(customeri); printf("请您选择预定房间的标准:n"); printf("1.单人间/天150元n2.双人间/天200元n3.标准间/天300元n4.总统套房/天600元n"); scanf("%d",&room_standard); printf("请输入预定天数n"); scanf("%d",&day); set_day(customeri,day); switch(room_standard) int n; case 1: printf("住房费用总共为: %d 元n",day*150); /计算住房费用 for(n=0;n<20;n+) /从第一个级别的房间中查找一个空闲的房间 if(roomn.state=0) /state=0表示该住房没有被预定的 printf("预定成功房间号码为: %dn",roomn.number); roomn.state=1; set_room_number(customeri,roomn.number); break; break; case 2: printf("住房费用总共为: %d 元n",day*200); for(n=20;n<40;n+) if(roomn.state=0) printf("预定成功房间号码为: %dn",roomn.number); roomn.state=1; set_room_number(customeri,roomn.number); break; break; case 3: printf("住房费用总共为: %d 元n",day*300); for(n=40;n<60;n+) if(roomn.state=0) printf("预定成功房间号码为: %dn",roomn.number); roomn.state=1; set_room_number(customeri,roomn.number); break; break; case 4: printf("住房费用总共为: %d 元n",day*600); for(n=60;n<80;n+) if(roomn.state=0) printf("预定成功房间号码为: %dn",roomn.number); roomn.state=1; set_room_number(customeri,roomn.number); break; break; i+; /住房的顾客数加1/入住登记*void check_in() char name110,id119; int ding_or_no,prepaid; int j; printf("该顾客订房了吗? (1->订了 2->没订) "); scanf("%d",&ding_or_no); if(ding_or_no=1) printf("请输入顾客的姓名:n"); scanf("%s",&name1); printf("请输入顾客的身份证号码:n"); scanf("%s",&id1); for(j=0;j<i;j+) if(strcmp(get_name(customerj),name1)=0)&&(strcmp(get_ID(customerj),id1)=0) /查找该顾客的定房信息 int num=get_room_number(customerj); /取得定房的房间号 printf("顾客 %s 今天入住本宾馆! 房间号码为: %dn",name1,num); switch(num/100) case 6: prepaid=get_day(customerj)*150; set_prepaid(customerj,prepaid); printf("请收房费 %d元整!n",prepaid); /开始收费 roomnum%100-1.state=2; /修改房间状态为入住状态 break; case 7: prepaid=get_day(customerj)*200; set_prepaid(customerj,prepaid); printf("请收房费 %d元整!n",prepaid); room19+num%100.state=2; break; case 8: prepaid=get_day(customerj)*300; set_prepaid(customerj,prepaid); printf("请收房费 %d元整!n",prepaid); room39+num%100.state=2; break; case 9: prepaid=get_day(customerj)*600; set_prepaid(customerj,prepaid); printf("请收房费 %d元整!n",prepaid); room59+num%100.state=2; break; break; else int room_standard,day; customeri = (struct Customer*)malloc(sizeof(struct Customer); CCustomer(customeri); printf("请您选择预定房间的标准:n"); printf("1.单人间/天150元n2.双人间/天200元n3.标准间/天300元n4.总统套房/天600元n"); scanf("%d",&room_standard); printf("请输入住宿天数n"); scanf("%d",&day); set_day(customeri,day); switch(room_standard) int n; case 1: prepaid=day*150; set_prepaid(customeri,prepaid); printf("请收房费 %d元整!n",prepaid); for(n=0;n<20;n+) if(roomn.state=0) printf("入住房间号码为: %dn",roomn.number); roomn.state=2; set_room_number(customeri,roomn.number); break; break; case 2: prepaid=day*200; set_prepaid(customeri,prepaid); printf("请收房费 %d元整!n",prepaid); for(n=20;n<40;n+) if(roomn.state=0) printf("入住房间号码为: %dn",roomn.number); roomn.state=2; set_room_number(customeri,roomn.number); break; break; case 3: prepaid=day*300; set_prepaid(customeri,prepaid); printf("请收房费 %d元整!n",prepaid); for(n=40;n<60;n+) if(roomn.state=0) printf("入住房间号码为: %dn",roomn.number); roomn.state=2; set_room_number(customeri,roomn.number); break; break; case 4: prepaid=day*600; set_prepaid(customeri,prepaid); printf("请收房费 %d元整!n",prepaid); for(n=60;n<80;n+) if(roomn.state=0) printf("入住房间号码为: %dn",roomn.number); roomn.state=2; set_room_number(customeri,roomn.number); break; break; i+; /退房结算*void check_out() char name210,id219; int standard,j,room_number,day1,day2,day; printf("请输入要退房的顾客姓名和身份证号码:n"); scanf("%s%s",&name2,&id2); printf("请输入该顾客实住天数:n"); scanf("%d",&day2); for(j=0;j<i;j+) if(strcmp(get_name(customerj),name2)=0)&&(strcmp(get_ID(customerj),id2)=0) char account; room_number=get_room_number(customerj); standard=room_number/100; day1=get_day(customerj); day=day1-day2; switch(standard) case 6: printf("顾客的房间号是%d :为单人间,每天150元n",room_number); printf("该顾客预付了房费 %d元, 实际消费 %d元整!n",get_prepaid(customerj),day2*150); printf("n"); if(day>0) printf("请退给该顾客 %d 元整!n",day*150); if(day<0) printf("请补收该顾客住房费 %d 元整!n",-day*150); break; case 7: printf("顾客的房间号是%d :为单人间,每天200元n",room_number); printf("该顾客预付了房费 %d元, 实际消费 %d元整!n",get_prepaid(customerj),day2*200); printf("n"); if(day>0) printf("请退给该顾客 %d 元整!n",day*200); if(day<0) printf("请补收该顾客住房费 %d 元整!n",-day*200); break; case 8: printf("顾客的房间号是%d :为单人间,每天300元n",room_number); printf("该顾客预付了房费 %d元, 实际消费 %d元整!n",get_prepaid(customerj),day2*300); printf("n"); if(day>0) printf("请退给该顾客 %d 元整!n",day*300); if(day<0) printf("请补收该顾客住房费 %d 元整!n",-day*300); break; case 9: printf("顾客的房间号是%d :为单人间,每天600元n",room_number); printf("该顾客预付了房费 %d元, 实际消费 %d元整!n",get_prepaid(customerj),day2*600); printf("n"); if(day>0) printf("请退给该顾客 %d 元整!n",day*600); if(day<0) printf("请补收该顾客住房费 %d 元整!n",-day*600); break; printf("n"); printf("退房核算清楚,请按1: "); fflush(stdin); scanf("%c",&account); if(account='1') int k; for(k=0;k<80;k+) if(roomk.number=get_room_number(customerj) roomk.state=0; i-; for(;j<i;j+) customerj=customerj+1; free(customeri); FCustomer(); /信息查询*void inquire() char inquire_choice; printf("房间信息查询请按1, 顾客信息查询请按2: "); fflush(stdin); scanf("%c",&inquire_choice); if(inquire_choice='1') int j,k=0; printf("n"); printf("下列房间还没人预订,也没人入住:n"); for(j=0;j<80;j+) if(roomj.state=0) if(k%10=0) printf("n"); printf("%dt",roomj.number); k+; printf("n"); printf("n"); k=0; printf("下列房间已预订:n"); for(j=0;j<80;j+) if(roomj.state=1) if(k%10=0) printf("n"); printf("%dt",roomj.number); k+; k=0; printf("n"); printf("n"); printf("下列房间有人入住:n"); for(j=0;j<80;j+) if(roomj.state=2) if(k%10=0) printf("n"); printf("%dt",roomj.number); k+; printf("n"); printf("n"); else if(inquire_choice='2') char inquire_choice; int j; printf("按姓名查询请按1, 按身份证查询请按2: n"); fflush(stdin); scanf("%c",&inquire_choice); if(inquire_choice='1') char name310; printf("请输入顾客的姓名: n"); scanf("%s",&name3); for(j=0;j<i;j+) if(strcmp(get_name(customerj),name3)=0) printf("%s的住房信息如下:n",name3); printf("t房间号为: %dn",get_room_number(customerj); printf("t预付房费为: %dn",get_prepaid(customerj); if(inquire_choice='2') char id310; int j; printf("请输入顾客的身份证: n"); scanf("%s",&id3); for(j=0;j<i;j+) if(strcmp(get_ID(customerj),id3)=0) printf("%s的住房信息如下:n",get_name(customerj); printf("t房间号为: %dn",get_room_number(customerj); printf("t预付房费为: %dn",get_prepaid(customerj); /房间信息初始化*void initial_room() /对80个房间进行初始化,分4个等级 int j,k=601; for(j=0;j<20;j+) roomj.number=k+; roomj.dank=1; roomj.price=150; roomj.state=0; k=701; for(j=20;j<40;j+) roomj.number=k+; roomj.dank=2; roomj.price=200; roomj.state=0; k=801; for(j=40;j<60;j+) roomj.number=k+; roomj.dank=3; roomj.price=300; roomj.state=0; k=901; for(j=60;j<80;j+) roomj.number=k+; roomj.dank=4; roomj.price=600; roomj.state=0; 分享给你的朋友吧:i贴吧 新浪微博 腾讯微博 QQ空间 人人网 豆瓣 MSN 对我有帮助1回答时间:2011-1-12 17:11 | 我来评论 | 检举