《C语言 宾馆客房管理系统.doc》由会员分享,可在线阅读,更多相关《C语言 宾馆客房管理系统.doc(14页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、C语言 宾馆客房管理系统!? 宾馆客房管理系统 宾馆的客房销售是宾馆的主要利润来源。要求针对客房的属性,如房号、房价(只要分为三个档次价格即可)、入住情况、维护状况进行分析编程,要求实现若干功能,如:能够随时地通过程序查看每间客房的状态,查讯各种价位的空房数量和具体房号、查讯各种价位客房的入住数量和房号,当前正在维修的所有客房房号,随时统计当月的销售总收入,在文件中记录每个房间入住和退房情况及单价、毛利收入,根据上个月的文件记录,次月可以统计上个月的销售总收入等等。该管理系统运行时是一个循环式的菜单选项,能依据选项选择各种功能。并能依据需求,将结果打印在屏幕或打印到文件中。 #include
2、#include #include /*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 c
3、hange; 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-p
4、repaid=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
5、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(); /验证
6、用户登陆,登陆成功显示欢迎信息 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(co
7、de,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_serv
8、ice4) | (kind_of_service1) 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(si
9、zeof(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;n20;
10、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;n40;n+) if(roomn.state=0) printf(预定成功房间号码为: %dn,roomn.number); roomn.state=1; set
11、_room_number(customeri,roomn.number); break; break; case 3: printf(住房费用总共为: %d 元n,day*300); for(n=40;n60;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订了 2-没订) ); scan
12、f(%d,&ding_or_no); if(ding_or_no=1) printf(请输入顾客的姓名:n); scanf(%s,&name1); printf(请输入顾客的身份证号码:n); scanf(%s,&id1); for(j=0;ji;j+) if(strcmp(get_name(customerj),name1)=0)&(strcmp(get_ID(customerj),id1)=0) /查找该顾客的定房信息 int num=get_room_number(customerj); /取得定房的房间号 printf(顾客 %s 今天入住本宾馆! 房间号码为: %dn,name1,n
13、um); 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; brea
14、k; 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
15、; 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
16、*150; set_prepaid(customeri,prepaid); printf(请收房费 %d元整!n,prepaid); for(n=0;n20;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
17、;n40;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;n60;n+) if(roomn.state=0) printf(入住房间号码为: %dn,roomn.number); roomn.state=
18、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;n80;n+) if(roomn.state=0) printf(入住房间号码为: %dn,roomn.number); roomn.state=2; set_room_number(customeri,roomn.number); break; break; i+; /退房结算*void c
19、heck_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;j0) printf(请退给该顾客 %d 元整!n,day*150); if(day0) printf(请退给该顾客 %d 元整!n,day*200); if(day0) printf(请退给该顾客 %d 元整!n,day*300); if(day0)
20、 printf(请退给该顾客 %d 元整!n,day*600); if(day0) printf(请补收该顾客住房费 %d 元整!n,-day*600); break; printf(n); printf(退房核算清楚,请按1: ); fflush(stdin); scanf(%c,&account); if(account=1) int k; for(k=0;k80;k+) if(roomk.number=get_room_number(customerj) roomk.state=0; i-; for(;ji;j+) customerj=customerj+1; free(customer
21、i); 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;j80;j+) if(roomj.state=0) if(k%10=0) printf(n); printf(%dt,roomj.number); k+; printf(n);
22、printf(n); k=0; printf(下列房间已预订:n); for(j=0;j80;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;j80;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
23、) 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;ji;j+) if(strcmp(get_name(customerj),name3)=0) printf(%s的住房信息如下:n,name3); printf(t房间号为: %dn,get_room_number(custom
24、erj); printf(t预付房费为: %dn,get_prepaid(customerj); if(inquire_choice=2) char id310; int j; printf(请输入顾客的身份证: n); scanf(%s,&id3); for(j=0;ji;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(custo
25、merj); /房间信息初始化*void initial_room() /对80个房间进行初始化,分4个等级 int j,k=601; for(j=0;j20;j+) roomj.number=k+; roomj.dank=1; roomj.price=150; roomj.state=0; k=701; for(j=20;j40;j+) roomj.number=k+; roomj.dank=2; roomj.price=200; roomj.state=0; k=801; for(j=40;j60;j+) roomj.number=k+; roomj.dank=3; roomj.price=300; roomj.state=0; k=901; for(j=60;j80;j+) roomj.number=k+; roomj.dank=4; roomj.price=600; roomj.state=0; 分享给你的朋友吧:i贴吧 新浪微博 腾讯微博 QQ空间 人人网 豆瓣 MSN 对我有帮助1回答时间:2011-1-12 17:11 | 我来评论 | 检举
限制150内