C语言知识程序设计酒店管理计划系统实验报告韩国齐.doc
-+课程设计报告书 题 目:酒店管理系统设计报告 专 业: 电子信息工程(移动互联网) 班 级: 一班 姓 名: 韩国齐 学 号: 201408103010 教 师: 朴海光 一:程序功能酒店系统管理包括:主菜单、查看客房入住情况、登记入住、修改客房信息、修改客房信息及退房六个功能模块。每个功能用一个函数来实现,从而达到功能的模块化。主菜单模块:主菜单模块包括1.查看客房入住情况、2.登记入住、3.客房信息修改、4. 退房及显示入住的总费用、5.返回主菜单、6.直接退出程序。 1)查看客房入住情况功能模块:主要功能是查看房间的入住情况和继续查看已入住的房间的客户信息。2)登记入住功能模块:采用结构体数组来记录客户的信息,包括姓名、性别、年龄、身份证号、入住时间,入住单价及入住人数,登记完一个房间后可选择继续下一个房间的登记,也可以选择返回主菜单进行其他功能的操作。3)修改客房信息功能模块:包括修改客户信息模块和修改房间信息模块。4)修改客户信息模块:主要功能是可选择性的修改客户某个信息,也可以一次性全部修改。5)修改客房信息功能模块:用来对客户换房时对客户信息和房间号的修改。实现的功能是只要输入客户以前住的房间号和现在想住的房间号, 就将客户的信息全部移到现在想住的房间上,而以前的房间将被置为未使用。6)退房及显示总费用功能模块:当客户退房时,将客户使用的客房置为未使用,删除客户信息。并且显示客户从入住到退房时的总费用。 二:程序代码#include<stdio.h>#include<string.h>#include<stdlib.h>#define M 80int j,s;int hj81=0;FILE *fp; /定义文件指针变量struct date /定义结构体类型int month;int day;int year;final;struct clientchar name20;int sex;int age;char ID_card20;int count;struct date start;struct hotelint price;int room_ID;struct client personal;roomM;void save(); /声明文件函数void check_siru(); /声明查看客房入住情况函数void registration_live(); /声明登记入住信息函数void modify_infor(); /声明修改客房信息函数void amend_one(); /声明修改个人信息函数void amend_room(); /声明修改房间信息函数void cost(); /声明退房及显示入住费用函数void get_back(); /声明返回主菜单函数void check_siru1(); /声明查看客房入住情况的调用函数void registration_live1(); /声明登记入住信息的调用函数void amend_one1(); /声明修改个人信息的调用函数void amend_room1(); /声明修改房间信息的调用函数void cost1(); /声明显示入住费用的调用函数 int main() /主函数int menu();void print_message();printf("nnnnn");print_message();menu();save();return 0;void print_message()printf("ttt 欢迎入住黄金酒店nnn");menu() /主菜单函数int n;printf("n");printf("ttt 主菜单 nn");printf("ttt 按 1 查看客房入住情况n");printf("ttt 按 2 登记入住信息n");printf("ttt 按 3 修改客房信息n");printf("ttt 按 4 退房、及显示入住费用n");printf("ttt 按 5 返回主菜单n");printf("ttt 按 6 退出程序n");printf("nt请输入要进行操作的选项(1、2、3、4、5、6): ");scanf("%d",&n);while(n<1|n>6)printf("ttt 输入错误,请重新输入选项!");scanf("%d",&n);switch(n)case 1:check_siru();break;case 2:registration_live();break;case 3:modify_infor();break;case 4:cost();break;case 5:get_back();break;case 6:exit(0);return 0;void check_siru() /查看房间使用情况函数int a,g,count=0;for(g=1;g<=80;g+)if(hjg=0)+count;elseif(hjg=1)printf("nttt正在使用的房间号:%d",g);printf("nnttt未使用的房间数:%d",count);printf("nnttt按 1 返回主菜单,按 2 继续: ");scanf("%d",&a);switch(a) case 1:menu();break; case 2: printf("nn"); printf("nttt请输入要查询的房间号: "); scanf("%d",&s); if(hjs=1) printf("nttt 姓名:%s",rooms.personal.name); printf("nttt性别(其中:1表示男,2表示女!):%d",rooms.personal.sex); printf("nttt 年龄:%d",rooms.personal.age); printf("nttt身份证号:%s",rooms.personal.ID_card); printf("nttt入住年份:%d",rooms.personal.start.year); printf("nttt 月:%d",rooms.personal.start.month); printf("nttt 日:%d",rooms.personal.start.day); printf("nttt 房间号:%d",rooms.room_ID); printf("nttt客房单价:%d",rooms.price); printf("nttt入住人数:%d",rooms.personal.count); printf("nnttt按 1 返回主菜单,按 2 继续n"); scanf("%d",&a); switch(a) case 1:menu();break; case 2:check_siru1();break; elseprintf("nttt该房间未被使用!");save();printf("nnttt按 1 返回主菜单,按 2 继续: ");scanf("%d",&a);switch(a) case 1:menu();break; case 2:check_siru1();break;void registration_live() /登记入住函数int a;printf("tt请输入登记的相关信息:n");printf("nttt房间号");scanf("%d",&j);roomj.room_ID=j;printf("nttt 姓名:");scanf("%s",roomj.personal.name);printf("nt性别(其中:1表示男,2表示女!):");scanf("%d",&roomj.personal.sex);printf("nttt 年龄:");scanf("%d",&roomj.personal.age);printf("nttt身份证号:");scanf("%s",roomj.personal.ID_card);printf("nttt入住年份:");scanf("%d",&roomj.personal.start.year);printf("nttt 月份:");scanf("%d",&roomj.personal.start.month);printf("nttt 日期:");scanf("%d",&roomj.personal.start.day);printf("nttt客房单价:");scanf("%d",&roomj.price);printf("ntt 请输入入住人数: ");scanf("%d",&roomj.personal.count);hjj=1;save();printf("nntt按 1 返回主菜单,按 2 继续: ");scanf("%d",&a);switch(a) case 1:menu();break; case 2:registration_live1();break;void modify_infor() /修改客房函数int r,m;printf("ttt 菜单 nnn");printf("ttt1:修改客户信息n");printf("ttt2:修改房间信息n");printf("ttt3:返回主菜单n");printf("ttt4:退出程序n");printf("nntt 请选择输入选项(1、2、3、4): ");scanf("%d",&m);if(m<1|m>3)r=1;else r=0;switch(m)case 1:amend_one1();break;case 2:amend_room1();break;case 3:menu();case 4:exit(0);save();void amend_one() /修改客人信息函数int i,q;char a20;printf("nnttt请输入现住的房间号: ");scanf("%d",&j);printf("nttt请选择您要修改的个人选项n");printf("ttt1:代表姓名 nttt2:代表性别(其中1表示男,2表示女) nttt3:年龄 nttt4:代表身份证号 nttt5:代表入住年份 nttt6:代表入住月份 nttt7:代表入住日期 nttt8:入住人数n");printf("ttt请选择输入选项(1、2、3、4、5、6、7、8): ");scanf("%d",&q);switch(q)int t,p;case 1:printf("nttt请输入新名字: ");scanf("%s",a);strcpy(roomj.personal.name,a);printf("nnttt按 1 返回主菜单,按 2 继续: ");scanf("%d",&i);switch(i) case 1:menu();break; case 2:amend_one1();break;case 2:printf("ntt请输入新性别(其中:1表示男,2表示女): ");scanf("%d",&p);roomj.personal.sex=p;printf("nnttt按 1 返回主菜单,按 2 继续: ");scanf("%d",&i);switch(i) case 1:menu();break; case 2:amend_one1();break;case 3:printf("nttt请输入年龄: ");scanf("%d",&p);roomj.personal.age=p;printf("nnttt按 1 返回主菜单,按 2 继续: ");scanf("%d",&i);switch(i) case 1:menu();break; case 2:amend_one1();break;case 4:printf("nttt请输入新身份证号: ");scanf("%s",roomj.personal.ID_card);printf("nnttt按 1 返回主菜单,按 2 继续: ");scanf("%d",&i);switch(i) case 1:menu();break; case 2:amend_one1();break;case 5:printf("nttt请输入新年份: ");scanf("%d",&p);roomj.personal.start.year=p;printf("nnttt按 1 返回主菜单,按 2 继续: ");scanf("%d",&i);switch(i)case 1:menu();break;case 2:amend_one1();break;case 6:printf("nttt请输入新月份: ");scanf("%d",&p);roomj.personal.start.month=p;printf("nnttt按 1 返回主菜单,按 2 继续: ");scanf("%d",&i);switch(i)case 1:menu();break;case 2:amend_one1();break;case 7:printf("nttt请输入新日期: ");scanf("%d",&p);roomj.personal.start.day=p;printf("nnttt按 1 返回主菜单,按 2 继续: ");scanf("%d",&i);switch(i)case 1:menu();break;case 2:amend_one1();break;case 8:printf("nttt请输入新入住人数: ");scanf("%d",&p);roomj.personal.count=p;printf("nnttt按 1 返回主菜单,按 2 继续: ");scanf("%d",&i);switch(i)case 1:menu();break;case 2:amend_one1();break;menu();void amend_room() /修改房间信息函数int a,l,x;printf("ntttt请输入你要修改的 客房信息nn");printf("tttt1:房间号nntttt2:客房单价nntttt3:入住人数nntttt4:返回nn");printf("ttt请选择输入选项(1、2、3、4): ");scanf("%d",&l);switch(l)case 1:printf("nttt请输入旧房号: ");scanf("%d",&j);printf("ttt请输入新房号: ");scanf("%d",&s);strcpy(rooms.personal.name,roomj.personal.name);/roomj.personal.name=0;rooms.personal.sex=roomj.personal.sex;roomj.personal.sex=0;rooms.personal.age=roomj.personal.age;roomj.personal.age=0;strcpy(rooms.personal.ID_card,roomj.personal.ID_card); /roomj.personal.ID_card=0;rooms.personal.start.year=roomj.personal.start.year;roomj.personal.start.year=0;rooms.personal.start.month=roomj.personal.start.month;roomj.personal.start.month=0;rooms.personal.start.day=roomj.personal.start.day;roomj.personal.start.day=0;rooms.room_ID=s;rooms.price=roomj.price;rooms.personal.count=roomj.personal.count;hjs=1;hjj=0;printf("nntt按 1 返回主菜单,按 2 继续: ");scanf("%d",&a);switch(a)case 1:menu();break;case 2:amend_room1();break;case 2:printf("nttt 请输入房号: ");scanf("%d",&s);printf("ttt请输入新单价: ");scanf("%d",&x);rooms.price=x;printf("nntt按 1 返回主菜单,按 2 继续: ");scanf("%d",&a);switch(a)case 1:menu();break;case 2:amend_room1();break;case 3:printf("nttt 请输入房号: ");scanf("%d",&s);printf("ttt请输入新入住人数: ");scanf("%d",&x);rooms.personal.count=x;printf("nntt按 1 返回主菜单,按 2 继续: ");scanf("%d",&a);switch(a)case 1:menu();break;case 2:amend_room1();break;case 4:break;save();menu();void cost() /退房、显示入住费用函数int a,i,sum;printf("ttt请输入房间号: ");scanf("%d",&j);roomj.room_ID=j;printf("nttt 入住年份:%d",roomj.personal.start.year);printf("nttt 月:%d",roomj.personal.start.month);printf("nttt 日:%d",roomj.personal.start.day);printf("nttt 房间单价为: ");printf("%d",roomj.price);printf("nttt请输入退房时间: ");printf("nttt 请输入年份: ");scanf("%d",&final.year);printf("nttt 请输入月份: ");scanf("%d",&final.month);printf("nttt 请输入日期: ");scanf("%d",&final.day);printf("nttt请输入入住天数: ");scanf("%d",&i);sum=roomj.price*i;printf("nttt 总费用sum=%dn",sum);hjj=0;save();printf("nntt按 1 返回主菜单,按 2 继续: ");scanf("%d",&a);switch(a) case 1:menu();break; case 2:cost1();break;void get_back() /返回主菜单的调用函数menu();void check_siru1() /声明查看客房入住情况的调用函数check_siru();void registration_live1() /声明登记入住信息的调用函数registration_live();void amend_one1() /声明修改个人信息的调用函数amend_one();void amend_room1() /声明修改房间信息的调用函数amend_room();void cost1() /声明显示入住费用的调用函数cost();void save()FILE *fp;int i;if(fp=fopen("客房管理.txt","w+")=NULL)printf("cannot open filen");exit(0);for(i=0;i<M;i+)if(fwrite(&roomi), sizeof(roomM),1,fp)!=1)printf("file write errorn");fflush(fp);fclose(fp);三:运行 (主菜单功能) ( 登记客户入住信息(可以按 2 继续登记下个房间客户的信息) (查看登记过的客户信息(刚刚登记的李明的信息已存在) (修改客户信息(这页修改的是名字,把李明改为张三)(这页查看修改的客户信息是否成功(已成功的把李明改为了张三)(这页继续修改客户信息(这里修改的是性别,把刚才的男(1)改为了女(2)(这里继续查看刚才修改的性别是否成功(这里已经把男(1)改成了女(2)依此类推下面的年龄、身份证号、入住年份、月份、日期、人数都依此方法修改。(修改房间信息(这里把刚才客户张三入住的45号房间换成了30号房间)(查看客户换的房间是否换成功(这里已经成功的把45号房换成了30号)(退房及显示入住总费用模块(这里已经退掉了30号房间)(查看退房是否成功(这里已经成功的退出了30号房间,已经没有房间在使用了)。 整个酒店管理系统的功能就如上图所示。