当前位置:文档之家› C++课程设计酒店宾馆房间管理系统

C++课程设计酒店宾馆房间管理系统

/*本程序包括6个cpp文件和一个h头文件,要分别写在Source Files 和Header Files中*/


/*main.cpp*/

#include
#include
int scan();
void xinxiluruhanshu();
void xinxixianshihanshu();
void xinxichaxunhanshu();
void xinxixiugaihanshu();
void tuifangjiesuanhanshu();
void main() //主函数
{

int i=0;
while(!i)
switch(scan())
{
case 1:
xinxiluruhanshu();
break;
case 2:
xinxixianshihanshu();
break;
case 3:
xinxichaxunhanshu();
break;
case 4:
xinxixiugaihanshu();
break;
case 5:
tuifangjiesuanhanshu();
break;
default:
cout<<"谢谢使用,再见!";
i=1;
break;
}

}
int scan()
{


int d;
system("cls");
cout<<" * * ****************************** * * ";
cout<<" * * * # # * * * ";
cout<<"*************************** 欢迎进入旅馆客房管理系统 ***************************";
cout<<" * * * * # # * * * * ";
cout<<" * * * * **************************** * * * * \n\n";
cout<<" 请选择所要进行的操作:\n\n";
cout<<" 1.客房信息录入请按 1\n";
cout<<" 2.显示客房信息请按 2\n";
cout<<" 3.客房信息查询请按 3\n";
cout<<" 4.客房信息修改请按 4\n";
cout<<" 5.客人退房结算请按 5\n\n";
cout<<" 其他键退出......\n";
cin>>d;
return(d);
}



/*客房结算函数.cpp*/

#include
#include
#include
#include
#include
#include"room结构体.h"
void tuifangjiesuanhanshu() //客房结算函数
{
room room[3];
int a;
cout<<" 请输入所要结算的房间号:"<cin>>a;
FILE * fp;
if((fp=fopen("信息存放处.txt","r"))==NULL)
{
cout<<" 不能打开“信息存放处.txt”";
exit(0);
}
for(int b=1;b<3;b++)
{
fread(&room[b],sizeof(room),1,fp);
}
cout<<" 尊敬的客户,您本次的总住宿费为:"<<(room[a].tuifangshijian-room[a].ruzhushijian)*100*(room[a].fangjianjiage)<<"元 "<<"预付费用为:"<getchar();
fclose(fp);
}


/*信息查询函数.cpp*/

#include
#include
#include
#include
#include
#include"room结构体.h"
int see();
void anfangjianhaochaxun();
void ankerenxingmingchaxun();
void anfangjiankonxianzhuangtaichaxun();
void anfangjianjiagechaxun();
void anfangj

ianleixingchaxun();
void xinxichaxunhanshu() //信息查询函数
{
switch(see())
{
case 1:
anfangjianhaochaxun();
break;
case 2:
ankerenxingmingchaxun();
break;
case 3:
anfangjiankonxianzhuangtaichaxun();
break;
case 4:
anfangjianjiagechaxun();
break;
case 5:
anfangjianleixingchaxun();
break;
default:
break;
}
}
void anfangjianhaochaxun() //按房间号查询
{ room room[3];


FILE * fp;
if((fp=fopen("信息存放处.txt","r"))==NULL)
{
cout<<"不能打开“信息存放处.txt”";
exit(0);
}
int a;
for(int i=1;i<3;i++)
{
fread(&room[i],sizeof(room),1,fp);}
cout<<" 请选择你要查询的房间号:"<cin>>a;
cout<<" 房间号码:"<cout<<" 房间类型(A代表上等房,B代表中等房,C代表下等房):"<cout<<" 房间价格:"<cout<<" 房间空闲情况(0表示空闲,1表示不空闲):"<cout<<" 客人姓名:"<cout<<" 客人身份证号码:"<cout<<" 入住时间:"<cout<<" 退房时间:"<cout<<" 预付费用(元):"<getchar();
fclose(fp);
}
void ankerenxingmingchaxun() //按客人姓名查询
{ room room[3];

int a=1;
FILE * fp;
if((fp=fopen("信息存放处.txt","r"))==NULL)
{
cout<<"不能打开“信息存放处.txt”";
exit(0);
}
char c[30];
cout<<"请输入客人姓名:"<cin>>c;
for(int b=1;b<3;b++)
{
fread(&room[b],sizeof(room),1,fp);

}
for(a=1;a<3;a++)
{
if(strcmp(room[a].kerenxingming,c)==0)
{
cout<<" 客人姓名:"<cout<<" 房间号码:"<cout<<" 房间类型(A代表上等房,B代表中等房,C代表下等房):"<cout<<" 房间价格:"<cout<<" 房间空闲情况(0表示空闲,1表示不空闲):"<cout<<" 客人身份证号码:"<cout<<" 入住时间:"<cout<<" 退房时间:"<cout<<" 预付费用(元):"<break;
}
else if(a==2)
cout<<" 输入的客人姓名不存在!";
}getchar();
//if (a==3)
fclose(fp);
}
void anfangjiankonxianzhuangtaichaxun() //按房间空闲状态查询
{
room room[3];


int t;
FILE * fp;
if((fp=fopen("信息存放处.txt","r"))==NULL)
{
cout<<"

不能打开“信息存放处.txt”";
exit(0);
}
cout<<" 请输入要查询房间的空闲状态(0表示空闲,1表示不空闲):"<cin>>t;
for(int b=1;b<3;b++)
{
fread(&room[b],sizeof(room),1,fp);
}
int a=1;
while(a<3)
{
if(t==room[a].fangjiankongxianqingkuang)
{
cout<<" 房间空闲情况(0表示空闲,1表示不空闲):"<cout<<" 房间号码:"<cout<<" 房间类型(A代表上等房,B代表中等房,C代表下等房):"<cout<<" 房间价格:"<cout<<" 客人姓名:"<cout<<" 客人身份证号码:"<cout<<" 入住时间:"<cout<<" 退房时间:"<cout<<" 预付费用(元):"<break;
}
else if(t!=room[a].fangjiankongxianqingkuang)
a++;
else
cout<<" 没有对应状态的房间!";
}
getchar();
fclose(fp);

}
void anfangjianjiagechaxun() //按房间价格查询
{
room room[3];

int t;
FILE * fp;
if((fp=fopen("信息存放处.txt","r"))==NULL)
{
cout<<" 不能打开“信息存放处.txt”";
exit(0);
}
cout<<" 请输入要查询的房间价格"<cin>>t;
for(int b=1;b<3;b++)
{
fread(&room[b],sizeof(room),1,fp);
}
for(int a=1;a<3;a++)
{
if(t==room[a].fangjianjiage)
{
cout<<" 房间价格:"<cout<<" 房间号码:"<cout<<" 房间空闲情况(0表示空闲,1表示不空闲):"<cout<<" 客人姓名:"<cout<<" 房间类型(A代表上等房,B代表中等房,C代表下等房):"<cout<<" 客人身份证号码:"<cout<<" 入住时间:"<cout<<" 退房时间:"<cout<<" 预付费用(元):"<}
else
cout<<"没有对应价格的房间!"<}
getchar();
fclose(fp);
}
void anfangjianleixingchaxun() //按房间类型查询
{
room room[3];

char t[5];
FILE * fp;
if((fp=fopen("信息存放处.txt","r"))==NULL)
{
cout<<" 不能打开“信息存放处.txt”";
exit(0);
}
cout<<" 请输入要查询的房间类型(A代表上等房,B代表中等房,C代表下等房):"<cin>>t;
for(int b=1;b<3;b++)
{
fread(&room[b],sizeof(room),1,fp);
}
for(int a=1;a<3;a++)
{
if(strcmp(room[a].f

angjianleixing,t)==0)
{
cout<<" 房间类型(A代表上等房,B代表中等房,C代表下等房):"<cout<<" 房间号码:"<cout<<" 房间价格:"<cout<<" 房间空闲情况(0表示空闲,1表示不空闲):"<cout<<" 客人姓名:"<cout<<" 客人身份证号码:"<cout<<" 入住时间:"<cout<<" 退房时间:"<cout<<" 预付费用(元):"<}
else
cout<<" 没有对应类型的房间!"<}
getchar();
fclose(fp);
}
int see()
{
int m;
system("cls");
cout<<" 请选择你要查询的方式:\n\n";
cout<<" 1.按房间号查询请按 1\n";
cout<<" 2.按客人姓名查询请按 2\n";
cout<<" 3.按房间空闲状态查询请按 3\n";
cout<<" 4.按房间价格查询请按 4\n";
cout<<" 5.按房间类型查询请按 5\n";
cout<<" 其他键退出......\n";
cin>>m;
return(m);
}



/*信息录入函数.cpp*/

#include
#include
#include
#include
#include
#include"room结构体.h"
void xinxiluruhanshu() //信息录入函数
{
room room[3]; //初始房间个数为3个

int a;
FILE * fp;
if((fp=fopen("信息存放处.txt","w"))==NULL)
{
cout<<"不能打开“信息存放处.txt”";
exit(0);
}
for(a=1;a<3;a++)
{
cout<<" 请选择所要录入信息的房间号(1,2):";
cin>>room[a].fangjianhaoma;
cout<<" 房间类型(A代表上等房,B代表中等房,C代表下等房):";
cin>>room[a].fangjianleixing;
cout<<" 房间价格(/天):";
cin>>room[a].fangjianjiage ;
cout<<" 房间空闲情况(0表示空闲,1表示不空闲):";
cin>>room[a].fangjiankongxianqingkuang;
cout<<" 客人姓名(用拼音全拼表示):";
cin>>room[a].kerenxingming ;
cout<<" 客人身份证号码:";
cin>>room[a].kerenshenfenzhenghaoma ;
cout<<" 客人入住时间(格式为xx.xx,如9月8日应输入为:9.08):" ;
cin>>room[a].ruzhushijian;
cout<<" 客人退房时间(格式为xx.xx,如9月8日应输入为:9.08):";
cin>>room[a].tuifangshijian ;
cout<<" 预付费用(元):" ;
cin>>room[a].yufufeiyong ;
if (room[a].yufufeiyong<(room[a].tuifangshijian-room[a].ruzhushijian)*100*(room[a].fangjianjiage))
{
cout<<" 预付费用小于预计总费用"<<(room[a].tuifangshijian-room[a].ruzhushijian)*100*(room[a].fangjianjiage)<<" "<<"请重新输入:";
cin>>room[a].yufufeiyong ;
}
fwrite(&room[a],sizeof(room),1,fp);
}
fclose(fp);
}




/*信息显示函数.cpp*/



#include
#include
#include
#include
#include
#include"room结构体.h"
void xinxixianshihanshu() //信息显示函数
{
room room[3];

int a;
FILE * fp;
if((fp=fopen("信息存放处.txt","r"))==NULL)
{
cout<<"不能打开“信息存放处.txt”";
exit(0);
}
for(a=1;a<3;a++)
{
fread(&room[a],sizeof(room),1,fp);
cout<<"********************************************************************************";
cout<<" 房间号码:"<cout<<" 房间类型(A代表上等房,B代表中等房,C代表下等房):"<cout<<" 房间价格:"<cout<<" 房间空闲情况(0表示空闲,1表示不空闲):"<cout<<" 客人姓名:"<cout<<" 客人身份证号码:"<cout<<" 入住时间:"<cout<<" 退房时间:"<cout<<" 预付费用(元):"<}
getchar();
fclose(fp);
}



/*信息修改函数.cpp*/

#include
#include
#include
#include
#include
#include"room结构体.h"
void xinxixiugaihanshu() //信息修改函数
{
room room[3];

int a;
FILE * fp;
if((fp=fopen("信息存放处.txt","r"))==NULL)
{
cout<<" 不能打开“信息存放处.txt”";
exit(0);
}
for(int b=1;b<3;b++)
{
fread(&room[b],sizeof(room),1,fp);
}
fclose(fp);
cout<<" 请输入需要修改信息的房间号:"<cin>>a;
cout<<" 房间类型(A代表上等房,B代表中等房,C代表下等房):";
cin>>room[a].fangjianleixing;
cout<<" 房间价格(/天):";
cin>>room[a].fangjianjiage ;
cout<<" 房间空闲情况(0表示空闲,1表示不空闲):";
cin>>room[a].fangjiankongxianqingkuang;
cout<<" 客人姓名(用拼音全拼表示):";
cin>>room[a].kerenxingming ;
cout<<" 客人身份证号码:";
cin>>room[a].kerenxingming ;
cout<<" 客人入住时间(格式为xx.xx,如9月8日应输入为:9.08):" ;
cin>>room[a].ruzhushijian;
cout<<" 客人退房时间(格式为xx.xx,如9月8日应输入为:9.08):";
cin>>room[a].tuifangshijian ;
cout<<" 预付费用(元):" ;
cin>>room[a].yufufeiyong ;
if((fp=fopen("信息存放处.txt","w"))==NULL)
{
cout<<" 不能打开“信息存放处.txt”";
exit(0);
}
fwrite(&room[a],sizeof(room),1,fp);
fclose(fp);
}



/*room结构体.h*/

#include
#include
#include
#include
#include
struct room //房间

结构体
{
int fangjianhaoma;
char fangjianleixing[5];
double fangjianjiage;
int fangjiankongxianqingkuang;
char kerenxingming[30];
int kerenshenfenzhenghaoma;
double ruzhushijian;
double tuifangshijian;
double yufufeiyong;
};
//room[3]; 初始房间个数为3个




相关主题
文本预览
相关文档 最新文档