《酒店房间登记与计费管理系统》

    技术2026-01-06  10

    #include<iostream> #include<stdio.h> #include<string> using namespace std; struct room { int name; int z;//表示入住状态,1为入住,0为空 char x;//表示入住方式 char vip;//记录是否为vip int hours;//每小时价格 int days;//每天价格 int day;//住的天数 int hour;//住的小时 }; room r[100]; void print() { cout<<"操作表"<<endl; cout<<"0.结束"<<endl; cout<<"1.登记入住"<<endl; cout<<"2.查询房间入住情况"<<endl; cout<<"3.查询某房间的费用"<<endl; cout<<"4.结账退房"<<endl; cout<<"5.查看操作表"<<endl; } void second(int n) { for(int i=1;i<=n;i++) { cout<<r[i].name<<" "<<r[i].z<<endl; } } void third(int k) { cout<<r[k].hour<<"/小时"<<endl; cout<<r[k].day<<"/天"<<endl; } void first(int n) { int k=1; cout<<"欢迎进入登记界面"<<endl; cout<<"当前房间入住情况如下"<<endl; second(n); cout<<"请输入查询价格的房间号"<<endl; int p; cin>>p; r[p].z=1;//切换成入住状态 third(p); cout<<"正在为您办理入住"<<endl; cout<<"请选择入住方式h为小时入住,d为天数入住"; char s; cin>>s; r[p].x=s; if(s=='h') { cout<<"请输入您要入住的小时数"<<endl; cin>>r[p].hours; cout<<"恭喜您入住成功"<<endl; return; } if(s=='d') { cout<<"请输入您要入住的天数"<<endl; cin>>r[p].days; cout<<"恭喜您入住成功"<<endl; return; } } void four() { cout<<"欢迎退房"<<endl; cout<<"请输入您的房间号"<<endl; int a; cin>>a; if(r[a].x=='h') { cout<<"您的入住时间是"<<r[a].hours<<"小时"<<endl; cout<<"您需要支付的费用为"<<r[a].hour*r[a].hours<<endl; cout<<"请问您是否有vip,y or n"<<endl; char g; cin>>g; if(g=='y') { cout<<"打九折,您的折扣费用为"<<r[a].hour*r[a].hours*0.9<<endl; } cout<<"欢迎下次光临"<<endl; r[a].name=0;//房间置为空 } if(r[a].x=='d') { cout<<"您的入住时间是"<<r[a].days<<"天"<<endl; cout<<"您需要支付的费用为"<<r[a].day*r[a].days<<endl; cout<<"请问您是否有vip,y or n"<<endl; char g; cin>>g; if(g=='y') { cout<<"打九折,您的折扣费用为"<<r[a].day*r[a].days*0.9<<endl; } cout<<"欢迎下次光临"<<endl; r[a].name=0;//房间置为空 } } int main() { cout<<"开始初始化"<<endl; cout<<"输入旅馆房间个数"<<endl; int n; cin>>n; for(int i=1;i<=n;i++) { r[i].name=i; r[i].day=0; r[i].hour=0; r[i].z=0; cout<<"输入房间"<<i<<"的小时单价和天数单价空格隔开"<<endl; cin>>r[i].hour>>r[i].day; } print(); int c=1,m; while(c) { cout<<"输入操作"<<endl; cin>>c; switch (c) { case 1: first(n); break; case 2: second(n); cout<<"入住情况如下"<<endl; break; case 3: cout<<"请输入查询价格的房间号"<<endl; cin>>m; third(m); break; case 4: four(); break; case 5: print(); break; default: cout<<"错误指令,请重新输入"<<endl; break; } } return 0; }
    Processed: 0.049, SQL: 10