酒店管理系统代码c语言版)

合集下载

酒店管理系统源代码

酒店管理系统源代码

酒店管理系统源代码#include<string.h>#include<stdlib.h>#include<stdio.h>#include<conio.h>typedef struct tagCustomer{char m_ID[19]; /*身份证号码*/ char m_name[10]; /*顾客姓名*/ int m_age; /*顾客年龄*/ char m_sex[6]; /*顾客性别*/ int num;}Customer;/*顾客结构*/typedef struct tagRoom{int m_num; /*房间号*/int m_floor; /*楼层*/int m_price; /*价格*/int m_use; /*是否已入住*/}Room;/*房间结构*/int i,j=0,age,num,floor,price,use,n;int reg =0;Customer cus[5];Room r[5];int count=5;char ID[18],name[10],sex[6];FILE *fproom;FILE *fpcustomer;void Customer_Input(){if(count<=5){printf("请输入身份证号(18位数字):");scanf("%s",&cus[j].m_ID);printf("请输入姓名(10位字符)");scanf("%s",&cus[j].m_name);printf("请输入年龄(数字型)");scanf("%d",&cus[j].m_age);printf("请输入性别(男或女):");scanf("%s",&cus[j].m_sex);}else{printf("\n 存储空间已满!");}printf("\n\r顾客可以住在:");printf("\n\r房间号楼层价格是否空闲(1:空闲0:已使用)");for(i=0;i<count;i++){if(r[i].m_use==1){printf("\n\r%d %d %d %d ",r[i].m_num,r[i].m_floor,r[i].m_price,r[i].m_use);}}printf("\n\r请你输入房间号:");scanf("%d",&num);reg = 0;for(i=0;i<count;i++){if(r[i].m_use==1&&r[i].m_num==num){r[i].m_use = 0;printf("\n 登记成功!\n");cus[j].num=r[i].m_num ;j=j+1;reg=1;}}if(reg==0){printf("\n 登记失败!\n");}}void Customer_ListOut(){if(count<=5){printf("请输入身份证号(18位数字):");scanf("%s",&ID);for(i=0;i<count;i++)if(strcmp(cus[i].m_ID,ID)==0){printf("\n\r顾客身份证号:%s 姓名:%s 年龄:%d 性别:%s \n",cus[i].m_ID,cus[i].m_name,cus[i].m_age,cus[i].m_sex);}}}else{printf("\n \n");}}void Room_ListOut(){printf("\n\r房间号楼层价格是否空闲(1:空闲0:已使用)");for(i=0;i<count;i++){if(r[i].m_use==1){printf("\n\r%d %d %d %d ",r[i].m_num,r[i].m_floor,r[i].m_price,r[i].m_use);}}}void PerCustomer_Search(){if(count<=5){printf("请输入身份证号(18位数字):");scanf("%s",&cus[j].m_ID);printf("请输入姓名(10位字符)");scanf("%s",&cus[j].m_name);printf("请输入年龄(数字型)");scanf("%d",&cus[j].m_age);printf("请输入性别(男或女):");scanf("%s",&cus[j].m_sex);}else{printf("\n 住房已满!");}printf("\n\r顾客可以预订:");printf("\n\r房间号楼层价格是否空闲(1:空闲0:已使用)");for(i=0;i<count;i++){if(r[i].m_use==1){printf("\n\r%d %d %d %d ",r[i].m_num,r[i].m_floor,r[i].m_price,r[i].m_use);}}printf("\n 请你输入要预订的房间号:");scanf("%d",&num);reg = 0;for(i=0;i<count;i++){if(r[i].m_use==1&&r[i].m_num==num){r[i].m_use = 0;printf("\n 预订成功!\n");cus[j].num=r[i].m_num ;j=j+1;reg=1;}}if(reg==0){printf("\n 预订失败!\n");}}void UnCustomer_Out(){int k;printf("\n 请输入要退房顾客身份证:");scanf("%s",&ID);for(i=0;i<count;i++){if(strcmp(cus[i].m_ID,ID)==0){printf("\n\r顾客身份证号:%s 姓名:%s 年龄:%d 性别:%s \n\r已经成功退房!",cus[i].m_ID,cus[i].m_name,cus[i].m_age,cus[i].m_sex);for(k=0;k<count;k++)if(r[k].m_num==cus[i].num)r[k].m_use=1;memset(&cus[i],0,sizeof(Customer));}}}void Customer_Goaway(){fproom=fopen("room","wb+");fwrite((void *)&r,sizeof(Room),count,fproom);fclose(fproom);fpcustomer=fopen("customer","wb+");fwrite((void*)&r,sizeof(Room),count,fpcustomer);fclose(fpcustomer);exit(0);}main(){fproom=fopen("room","wb");if(fproom!=NULL){for(i=0;i<count;i++){int id=100;r[i].m_num=i+100;r[i].m_floor=1;r[i].m_price=100;r[i].m_use=1;}fwrite((void *)&r,sizeof(Room),count,fproom);fclose(fproom);}else{printf("\n---文件打开失败--");}for(;;){printf("\n");printf("/******************************************\\\n ");printf("**\n");printf("* 酒店管理系统*\n");printf("* 主菜单*\n");printf("**\n");printf("* 1.顾客登记*\n");printf("* 2.查询顾客信息*\n");printf("* 3.查询空房间*\n");printf("* 4.预订房间*\n");printf("* 5.退订房间*\n");printf("* 6.保存并退出系统*\n");printf("**\n");printf("\\******************************************/\n\ n");printf("请输入选择项(1-6):");scanf("%d",&n);printf("\n\n\n\n");if(n>0&&n<=6){switch(n){case 1:Customer_Input();break;case 2:Customer_ListOut();break;/*查询顾客信息*/case 3:Room_ListOut();break;/*查询空房间*/case 4:PerCustomer_Search();break;/*预订房间*/case 5:UnCustomer_Out();break;/*退订房间*/case 6:Customer_Goaway(); /*保存退出*/}}else{printf("********************************************* **************************\n");printf("**\n");printf("*输入错误! *\n");printf("*请退出! *\n");printf("**\n");printf("********************************************* **************************\n");break;}} }。

酒店管理系统c语言程序设计

酒店管理系统c语言程序设计

酒店管理系统c语言程序设计以下是一个简单的酒店管理系统的 C 语言程序设计示例,包括了客户入住、退房和查询房间状态等基本功能。

请注意,这只是一个简化的示例,实际的酒店管理系统可能需要更多的功能和复杂的逻辑。

```c#include <stdio.h>#include <stdlib.h>#include <string.h>#define MAX_ROOMS 100#define MAX_CUSTOMERS 100// 房间结构体struct Room {int roomNumber;int isOccupied;int customerID;};// 客户结构体struct Customer {int customerID;char customerName[50];};// 房间列表struct Room rooms[MAX_ROOMS];// 客户列表struct Customer customers[MAX_CUSTOMERS];// 初始化房间列表void initRooms() {for (int i = 0; i < MAX_ROOMS; i++) {rooms[i].roomNumber = i + 1;rooms[i].isOccupied = 0;rooms[i].customerID = 0;}}// 初始化客户列表void initCustomers() {for (int i = 0; i < MAX_CUSTOMERS; i++) {customers[i].customerID = i + 1;strcpy(customers[i].customerName, "Customer");}}// 查找空闲房间int findFreeRoom() {for (int i = 0; i < MAX_ROOMS; i++) {if (rooms[i].isOccupied == 0) {return i;}}return -1;}// 客户入住void checkIn(int customerID, int roomNumber) {int freeRoom = findFreeRoom();if (freeRoom != -1) {rooms[freeRoom].isOccupied = 1;rooms[freeRoom].customerID = customerID;printf("Customer %d checked in to Room %d\n", customerID, roomNumber); } else {printf("No free rooms available\n");}}// 客户退房void checkOut(int roomNumber) {for (int i = 0; i < MAX_ROOMS; i++) {if (rooms[i].roomNumber == roomNumber && rooms[i].isOccupied == 1) { rooms[i].isOccupied = 0;rooms[i].customerID = 0;printf("Customer checked out of Room %d\n", roomNumber);return;}}printf("Room not found\n");}// 查询房间状态void viewRoomStatus(int roomNumber) {for (int i = 0; i < MAX_ROOMS; i++) {if (rooms[i].roomNumber == roomNumber) {if (rooms[i].isOccupied == 1) {printf("Room %d is occupied by Customer %d\n", roomNumber, rooms[i].customerID);} else {printf("Room %d is vacant\n", roomNumber);}return;}}printf("Room not found\n");}// 主函数int main() {initRooms();initCustomers();int choice;while (1) {printf("1. Check In\n2. Check Out\n3. View Room Status\n4. Exit\n"); scanf("%d", &choice);switch (choice) {case 1:int customerID, roomNumber;printf("Enter customer ID: ");scanf("%d", &customerID);printf("Enter room number: ");scanf("%d", &roomNumber);checkIn(customerID, roomNumber);break;case 2:printf("Enter room number: ");scanf("%d", &roomNumber);checkOut(roomNumber);break;case 3:printf("Enter room number: ");scanf("%d", &roomNumber);viewRoomStatus(roomNumber);break;case 4:exit(0);break;default:printf("Invalid choice\n");}}return 0;}```上述代码实现了一个简单的酒店管理系统,包括客户入住、退房和查询房间状态等功能。

(完整版)C语言酒店管理系统

(完整版)C语言酒店管理系统
}
for(y=0;y<5;y++)
{
if(room[x][y]==0)
{
printf("空%d-%d |",x+1,y+1);
}else
{
printf("住%d-%d |",x+1,y+1);
}
if(y+1==5)
{
if(x+1==1||x+1==2)
printf("该层标间均50元");
else
printf("该层标间均100元");
printf("\t2.查询房间的入住情况\n");
printf("\t3.查询当前费用\n");
printf("\t4.结账退房\n");
printf("\t5.退出程序\n");
}
void hotel_execute();
void hotel_select();
void hotel_outhotel();
{
printf("|-------|--------|--------|--------|--------|--------|\n|第%d层|",x+|-------|--------|--------|--------|--------|--------|\n|第%d层|",x+1);
}
}
}
printf("\n|-------|--------|--------|--------|--------|--------|\n");

酒店管理系统C语言版

酒店管理系统C语言版

#i n c l u d e<s t d i o.h>#include<stdlib.h>struct peopledata{char name[11];char sex[3];int age;int idcard[2];};struct datefflush(stdin);printf("房间类型:");scanf("%c",&room.kind);printf("住宿人员信息:\n");printf("\t\t姓名:");fflush(stdin);scanf("%s",);fflush(stdin);printf("\t\t性别:");gets(room.people.sex);printf("\t\t年龄:");scanf("%d",&room.people.age);printf("\t\t请输入身份证号码:");for(i=0;i<2;i++)scanf("%d",&room.people.idcard[i]); printf("入住时间:\n");printf("\t\t年:");scanf("%d",&room.time.year);printf("\t\t月:");scanf("%d",&room.time.month);printf("\t\t日:");scanf("%c",&tag);fflush(stdin);}else{printf("要继续添加吗?(y/n)\n");scanf("%c",&tag);fflush(stdin);}}fclose(fp);} while(tag=='y');}void updata(){FILE *fp;rooms room;int number,i;printf("请输入要更新的信息的房间编号:\n");scanf("%d",&number);printf("\t\t姓名\t性别\t年龄");printf("\t\t%s\t%s\t%d\n",,room.people.sex,room.people.age);printf("身份证号:");for(i=0;i<2;i++)printf("%d",room.people.idcard[i]);putchar('\n');printf("入住时间:\n");printf("%d年%d月%d日\n",room.time.year,room.time.month,room.time.day);printf("入住时长:\n");printf("%d天\n",room.time.time);printf("\t————————————————\n");printf("*******************************************************\n");printf("请输入更新信息:\n");printf("房间编号:");scanf("%d",&room.number);fflush(stdin);printf("房间类型:");scanf("%c",&room.kind);printf("住宿人员信息:\n");printf("\t\t姓名:");fflush(stdin);void searchdata(){FILE *fp;rooms room;int number,i;printf("请输入要查询的信息的房间编号:\n");scanf("%d",&number);if((fp=fopen("d:\\酒店住宿登记表.txt","r+"))==NULL){printf("打开文件”酒店住宿登记表“失败,按任意键退出。

酒店管理系统代码

酒店管理系统代码

附录Base.Dlg.cpp程序:#include "stdafx.h"#include "MyPos.h"#include "BaseDlg.h"#include "MaterielDlg.h"#include "ClassDlg.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif/////////////////////////////////////////////////////////////////////////////// CBaseDlg dialogCBaseDlg::CBaseDlg(CWnd* pParent /*=NULL*/): CDialog(CBaseDlg::IDD, pParent){//{{AFX_DATA_INIT(CBaseDlg)// NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT}void CBaseDlg::DoDataExchange(CDataExchange* pDX){CDialog::DoDataExchange(pDX);//{{AFX_DATA_MAP(CBaseDlg)DDX_Control(pDX, IDC_TAB_BASE, m_oTabBase);//}}AFX_DATA_MAP}BEGIN_MESSAGE_MAP(CBaseDlg, CDialog)//{{AFX_MSG_MAP(CBaseDlg)//}}AFX_MSG_MAPEND_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// CBaseDlg message handlersBOOL CBaseDlg::OnInitDialog(){CDialog::OnInitDialog();// TODO: Add extra initialization herem_oTabBase.AddPage("商品类别", &m_oClassdlg, IDD_DIALOG_CLASS);m_oTabBase.AddPage("商品资料", &m_oMaterieldlg, IDD_DIALOG_MA TERIEL);m_oTabBase.AddPage("付款方式", &m_oPaymodedlg, IDD_DIALOG_PAYMODE);m_oTabBase.Show();return TRUE; // return TRUE unless you set the focus to a control// EXCEPTION: OCX Property Pages should return FALSE}CallDlg.cpp程序:#include "stdafx.h"#include "MyPos.h"#include "CallDlg.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif/////////////////////////////////////////////////////////////////////////////// CCallDlg dialogextern CMyPosApp theApp;CCallDlg::CCallDlg(CWnd* pParent /*=NULL*/): CDialog(CCallDlg::IDD, pParent){//{{AFX_DATA_INIT(CCallDlg)// NOTE: the ClassWizard will add member initialization here//}}AFX_DATA_INIT}void CCallDlg::DoDataExchange(CDataExchange* pDX){CDialog::DoDataExchange(pDX);//{{AFX_DATA_MAP(CCallDlg)DDX_Control(pDX, IDC_STATIC_CALL, m_oCallstatic);DDX_Control(pDX, IDC_EDIT_CALLBILLID, m_oCallbillid);//}}AFX_DATA_MAP}BEGIN_MESSAGE_MAP(CCallDlg, CDialog)//{{AFX_MSG_MAP(CCallDlg)//}}AFX_MSG_MAPEND_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// CCallDlg message handlersvoid CCallDlg::OnOK(){if(dowhat=="imhappy"){theApp.scallid="";m_oCallbillid.GetWindowText(theApp.scallid);}if(dowhat=="pleased")m_oCallbillid.GetWindowText(dowhat);CDialog::OnOK();}BOOL CCallDlg::OnInitDialog(){CDialog::OnInitDialog();if(dowhat=="pleased")m_oCallstatic.SetWindowText("请输入桌号:");return TRUE; // return TRUE unless you set the focus to a control// EXCEPTION: OCX Property Pages should return FALSE }CheckDlg.cpp程序:#include "stdafx.h"#include "MyPos.h"#include "CheckDlg.h"#include "PosDlg.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif/////////////////////////////////////////////////////////////////////////////// CCheckDlg dialogextern CMyPosApp theApp;CCheckDlg::CCheckDlg(CWnd* pParent /*=NULL*/): CDialog(CCheckDlg::IDD, pParent){//{{AFX_DATA_INIT(CCheckDlg)//}}AFX_DATA_INIT}void CCheckDlg::DoDataExchange(CDataExchange* pDX){CDialog::DoDataExchange(pDX);//{{AFX_DATA_MAP(CCheckDlg)DDX_Control(pDX, IDC_EDIT_CONSUME, m_oConsume);DDX_Control(pDX, IDC_EDIT_CDISCOUNT, m_oCdiscount);DDX_Control(pDX, IDC_EDIT_RECEIVE, m_oReceive);DDX_Control(pDX, IDC_EDIT_CHANGE, m_oChange);DDX_Control(pDX, IDC_EDIT_TOTALM, m_oTotalm);DDX_Control(pDX, IDC_COMBO_PAYMODE, m_oCombopay);DDX_Control(pDX, IDC_LIST_CHECKLIST, m_oChecklist);//}}AFX_DATA_MAP}BEGIN_MESSAGE_MAP(CCheckDlg, CDialog)//{{AFX_MSG_MAP(CCheckDlg)ON_BN_CLICKED(IDC_BUTTON_CHECKOK, OnButtonCheckok)ON_EN_CHANGE(IDC_EDIT_RECEIVE, OnChangeEditReceive)ON_NOTIFY(NM_CLICK, IDC_LIST_CHECKLIST, OnClickListChecklist) ON_EN_CHANGE(IDC_EDIT_CDISCOUNT, OnChangeEditCdiscount)ON_BN_CLICKED(IDC_BUTTON_RF, OnButtonRf)ON_BN_CLICKED(IDC_BUTTON_HANG, OnButtonHang)//}}AFX_MSG_MAPEND_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// CCheckDlg message handlersBOOL CCheckDlg::OnInitDialog(){CDialog::OnInitDialog();//设置list控件的文字和背景颜色m_oChecklist.SetBkColor(RGB(255,255,255));m_oChecklist.SetTextBkColor(RGB(161,223,212));//清空list控件的数据for(int delcolumn=100;delcolumn>=0;delcolumn--)m_oChecklist.DeleteColumn(delcolumn);//设置list对话框的列DWORD dwStyle;RECT rect;LV_COLUMN lvc;dwStyle = m_oChecklist.GetStyle();dwStyle |= LVS_EX_GRIDLINES |LVS_EX_FULLROWSELECT|LVS_SHOWSELALWAYS ;m_oChecklist.SetExtendedStyle(dwStyle);m_oChecklist.GetClientRect(&rect);lvc.mask = LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH |LVCF_FMT;lvc.fmt=LVCFMT_LEFT;lvc.iSubItem = 0;lvc.pszText = _T("商品类别");lvc.cx = 110;m_oChecklist.InsertColumn(1,&lvc);lvc.iSubItem = 1;lvc.pszText = _T("消费金额");lvc.cx = 90;m_oChecklist.InsertColumn(2,&lvc);lvc.iSubItem = 2;lvc.pszText = _T("可折扣金额");lvc.cx = 90;m_oChecklist.InsertColumn(3,&lvc);lvc.iSubItem = 3;lvc.pszText = _T("折扣%");lvc.cx = 60;m_oChecklist.InsertColumn(4,&lvc);lvc.iSubItem = 4;lvc.pszText = _T("结帐金额");lvc.cx = 90;m_oChecklist.InsertColumn(5,&lvc);//Add paymode to combobox._RecordsetPtr m_pRecordset;CString sql="select * from PAYMODE";try{m_pRecordset.CreateInstance("ADODB.Recordset");m_pRecordset->Open((_variant_t)sql,_variant_t((IDispatch*)theApp.m_pConnection,true),a dOpenStatic,adLockOptimistic,adCmdText);while(!m_pRecordset->adoEOF){m_oCombopay.AddString((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("NAME"));m_pRecordset->MoveNext();}m_pRecordset->Close();m_oCombopay.SetCurSel(0);//Select the 1st string of combobox.}catch(_com_error e)///捕捉异常{CString temp;temp.Format("[结帐]读取付款方式到组合框出错:%s",e.ErrorMessage());AfxMessageBox(temp);}//Read class consume to list.ReadtoList(theApp.scallid);//Sum bill Items money from database.CString stotal;float ftotal=0;sql="Select SUM(ITEMTOTAL) as SSS from SALEDETAIL where BILLID='"+theApp.scallid+"'";try{m_pRecordset.CreateInstance("ADODB.Recordset");m_pRecordset->Open((_variant_t)sql,_variant_t((IDispatch*)theApp.m_pConnection,true),a dOpenStatic,adLockOptimistic,adCmdText);_variant_t vtemp = m_pRecordset->GetCollect("SSS");if(vtemp.dblVal>0)ftotal=(float)m_pRecordset->GetCollect("SSS");elseftotal=0;stotal.Format("%.2f",ftotal);m_oTotalm.SetWindowText(stotal);m_oConsume.SetWindowText(stotal);}catch(_com_error e)///捕捉异常{CString temp;temp.Format("[结帐]计算单据商品金额出错:%s",e.ErrorMessage());AfxMessageBox(temp);}return TRUE; // return TRUE unless you set the focus to a control// EXCEPTION: OCX Property Pages should return FALSE}void CCheckDlg::OnButtonCheckok(){CString stotal,sbilltotal,spayID,sql,spaymode,snowtime;long lpayID;_RecordsetPtr m_pRecordset;m_oConsume.GetWindowText(stotal);m_oTotalm.GetWindowText(sbilltotal);int nselect=m_oCombopay.GetCurSel();m_oCombopay.GetLBText(nselect,spaymode);lpayID=GetPaymodeID(spaymode);spayID.Format("%d",lpayID);if(fchange<0)return;//得到系统时间CTime now=CTime::GetCurrentTime();snowtime=now.Format(_T("%Y-%m-%d %H:%M:%S"));sql="Update SALEBILL set ENDDATE='"+snowtime+"',SALES='"++"',TOTAL="+stotal+",ACTTOTAL="+sbilltotal+",STATUS='已结帐',PAYMODE="+spayID+" where ID='"+theApp.scallid+"'";try{_variant_t RecordsAffected;theApp.m_pConnection->Execute((_bstr_t)sql,&RecordsAffected,adCmdText);}catch(_com_error e)///捕捉异常{CString temp;temp.Format("[结帐]单据头更新数据库出错:%s",e.ErrorMessage());AfxMessageBox(temp);return;}//output the checkout time and paymode to the print.theApp.snowtimep=snowtime;theApp.spaymodep=spaymode;theApp.sconsume=stotal;theApp.sactsum=sbilltotal;//Insert data into PAYDETAIL.CString sclass,scontotal,sdiscount,sacttotal,svaltotal;int nItemCount=m_oChecklist.GetItemCount();//表项总数for(int i=0;i<nItemCount;i++){sclass=m_oChecklist.GetItemText(i,0);scontotal=m_oChecklist.GetItemText(i,1);sdiscount=m_oChecklist.GetItemText(i,3);sacttotal=m_oChecklist.GetItemText(i,4);float fvaltotal=atof(scontotal)-atof(sacttotal);svaltotal.Format("%.2f",fvaltotal);sql="Insert into PAYDETAIL(BILLID,CLASS,TOTAL,DISCOUNT,ACTTOTAL,VALTOTAL)values('"+theApp.scallid+"','"+sclass+"',"+scontotal+",'"+sdiscount+"',"+sacttotal+","+svaltotal+")";try{_variant_t RecordsAffected;theApp.m_pConnection->Execute((_bstr_t)sql,&RecordsAffected,adCmdText);}catch(_com_error e)///捕捉异常{CString temp;temp.Format("[结帐]付款明细(PAYDETAIL)插入数据出错:%s",e.ErrorMessage());AfxMessageBox(temp);return;}}//When the check button is click down,send a message(WM_CHECKOUT) to the CPosDlg.LRESULT Res=::SendMessage(theApp.pWnd, WM_CHECKOUT, 0, 0);CDialog::OnOK();}long CCheckDlg::GetPaymodeID(CString payname){long paymodeID;_RecordsetPtr m_pRecordset;CString sql="Select * from PAYMODE where NAME='"+payname+"'";try{m_pRecordset.CreateInstance("ADODB.Recordset");m_pRecordset->Open((_variant_t)sql,_variant_t((IDispatch*)theApp.m_pConnection,true),a dOpenStatic,adLockOptimistic,adCmdText);paymodeID=(long)m_pRecordset->GetCollect("ID");}catch(_com_error e)///捕捉异常{CString temp;temp.Format("[结帐]获取付款方式ID出错:%s",e.ErrorMessage());AfxMessageBox(temp);}return paymodeID;}void CCheckDlg::OnChangeEditReceive(){// TODO: If this is a RICHEDIT control, the control will not// send this notification unless you override the CDialog::OnInitDialog()// function and call CRichEditCtrl().SetEventMask()// with the ENM_CHANGE flag ORed into the mask.CString sreceive,schange,stotal;m_oChange.SetWindowText("");m_oReceive.GetWindowText(sreceive);m_oTotalm.GetWindowText(stotal);fchange=atof(sreceive)-atof(stotal);if(fchange>=0){schange.Format("%.2f",fchange);m_oChange.SetWindowText(schange);}}void CCheckDlg::ReadtoList(CString sbillid){_RecordsetPtr m_pRecordset; //Must define it in functionCString sql,sclassname,sclassname1,sctotal;long lclassid;float fctotal=0;sql="Select Sum(ITEMTOTAL) as XXX,CLASSID from SALEDETAIL where BILLID='"+sbillid+"' group by CLASSID ";//删除所有list中的数据。

C语言宾馆管理系统源代码

C语言宾馆管理系统源代码
}
else
{
printf("要删除的话就按1:");
scanf("%d",&i);
if(i==1)
{
q=head;
while(q!=NULL&&q->next!=p)
q=q->next;
q->next=p->next;
}
while(b--)
{
p=(listnode *)malloc(sizeof(listnode));
printf("姓名 性别 证件 入住 天数 房号 标准 价格 预收 押金 离开 备注\n");
printf("**********************************************************************\n");
printf("*******************************************\n");
printf("姓名查找,按1表示查找:");
p=head->next;
scanf("%d",&i);
if(i==1)
{
printf("请输入要查询的姓名:");
scanf("%s",&come);
while(p&&strcmp(p->e,come)<0)
p=p->next;
if(p==NULL||strcmp(p->e,come)>0)

C语言课程设计---酒店房间登记与计费管理系统源代码

C语言课程设计---酒店房间登记与计费管理系统源代码

酒店房间登记与计费管理系统源代码#define M 80#include<>#include<>#include<>/*函数声明*/void check_in(); /*登记入住函数*/。

void chamber(); /*入住情况函数*/void price(); /*当前费用函数*/void fee(); /*结账退房函数*/void infor(); /*信息查询函数*/void save(int); /*保存信息函数*/void read(int); /*读取信息函数*/void choice(); /*功能选择函数*/int judge_year(int); /*判断闰年函数*/|void information(); /*输出全部房间信息*//*结构体*/struct time{int year;int mon;int date;int hour;"};struct room /*定义各房间信息的结构体*/{char name[40];char ID[18];int flag; /* 0-无人入住,1-按小时计费,2-按天计费*/ long int deposit;time t[2]; /* 0-入住时间,1-当前时间*/》}room[M];char c1[40]={0};char c2[18]={0};/*主函数(主界面)*/void main(){system("cls"); /*清屏*/system("color 4E");、int n;printf("********************************************************** **********************");printf("****");printf("**\t\t ---------- 欢迎光临万豪酒店---------- **");printf("****");printf("********************************************************** **********************\n\n");printf("\t\t\t [ 1. 登记入住]\n\n");printf("\t\t\t [ 2. 入住情况]\n\n");—printf("\t\t\t [ 3. 当前费用]\n\n");printf("\t\t\t [ 4. 结账退房]\n\n");printf("\t\t\t [ 5. 信息查询]\n\n");printf("\t\t\t [ 6. 全部信息]\n\n");printf("\t\t\t [ 7. 退出系统]\n\n");printf("请输入您需要的服务的代码:");scanf("%d",&n);while(n<1||n>7);{printf("\n\n代码输入有误,请您重新输入:");scanf("%d",&n);}switch(n) /*根据输入数字选择功能*/ {case 1:check_in();break; /*调用登记入住函数*/case 2:chamber();break; /*调用房间情况函数*/case 3:price();break; /*调用当前费用函数*/case 4:fee();break; /*调用结账退房函数*/·case 5:infor();break; /*调用信息查询函数*/case 6:information();break; /*调用全部信息函数*/case 7:exit(0); /*调用退出系统函数*/}}/*查看房间使用情况函数*/void chamber()·{system("cls"); /*清屏*/system("color 4E");printf("\n**********************************房间使用情况**********************************\n");int count=0;int i;int j;int k;int m;—for(i=1;i<=80;i++) /*统计未入住房间总数*/{read(i);if(room[i-1].flag==0)count++;}printf("当前未使用房间数:%d\n\n\n",count);chaxun:printf("请输入你要查询的房间号(1-40:单人间,41-80:双人间):");/*输入房间号查询房间入住情况*/~scanf("%d",&m);while(m<1||m>80){printf("\n\n房间号输入有误,请您重新输入:");scanf("%d",&m);}read(m);while(room[m-1].flag!=0){printf("\n\n对不起,该房间已有客人入住,请输入其他房间号:");|scanf("%d",&m);read(m);}printf("\n\n该房间没有客人入住,您要入住该房间吗(1-是,2-否):"); scanf("%d",&j);while(j<1||j>2){printf("\n\n您的选择输入有误,请您重新输入:");scanf("%d",&j);}^if(j==1)check_in();else{printf("\n\n您需要继续查询吗(1-是,2-否):");scanf("%d",&k);while(k<1||k>2){printf("\n\n您的选择输入有误,请您重新输入:");scanf("%d",&k);)}if(k==1)goto chaxun;else{printf("\n\n");main();}}}/*登记入住函数*/void check_in(){system("cls"); /*清屏*/system("color 4E");int i;int j;int l;:int k;int tab[2][12]={{31,28,31,30,31,30,31,31,30,31,30,31},{31,29,31,30,31,30,31,31,30,31,30,31}};printf("\n************************************登记入住************************************\n");printf("请输入您将入住的房间号:");scanf("%d",&i);while(i<1||i>80){printf("\n\n房间号输入有误,请您重新输入:");%scanf("%d",&i);}read(i);while(room[i-1].flag!=0) /*判断房间是否入住*/ {printf("\n\n对不起,该房间已有客人入住,请输入其他房间号:"); scanf("%d",&i);read(i);}printf("\n\n请输入您的姓名:"); /*客人信息登记*/|scanf("%s",room[i-1].name);j=strlen(room[i-1].name);while(j<0){printf("\n\n您的姓名输入有误,请您重新输入:\n");scanf("%s",room[i-1].name);j=strlen(room[i-1].name);}printf("\n\n请输入您的证件号码:");。

酒店管理系统c语言

酒店管理系统c语言

酒店管理系统1. 引言酒店管理系统是一种用于管理酒店日常运营的软件系统。

它可以帮助酒店管理人员提高工作效率,提供优质的服务,实现酒店的可持续发展。

本文将介绍一个基于C 语言开发的酒店管理系统,包括系统的功能设计、数据库设计、用户界面设计以及系统测试等内容。

2. 功能设计2.1 客房管理客房管理是酒店管理系统最重要的功能之一。

在该功能下,可以实现以下操作:•客房信息录入:输入客房号码、类型、价格等信息。

•客房信息查询:根据客房号码或类型查询客房信息。

•客房信息修改:修改客房的价格、状态等信息。

•客房状态查询:查询客房的入住状态。

2.2 预订管理预订管理是指对客户预订酒店客房的操作。

在该功能下,可以实现以下操作:•房间预订:根据客户需求,预订适合的客房。

•预订查询:查询已预订的客房信息。

•预订取消:取消已预订的客房。

2.3 入住管理入住管理是指客户入住酒店的操作。

在该功能下,可以实现以下操作:•入住登记:输入客户信息,将客户分配到合适的客房。

•入住查询:查询已入住客房的信息。

•退房办理:将已入住客房标记为可用状态。

2.4 结算管理结算管理是指对客户住宿费用进行结算的操作。

在该功能下,可以实现以下操作:•账单生成:根据客户入住情况,生成相应的账单。

•账单查询:查询客户的消费情况。

•结算处理:对客户账单进行结算。

3. 数据库设计酒店管理系统需要使用数据库来存储和管理数据。

以下是数据库设计的关键表格:3.1 客房信息表字段名类型描述RoomID int 客房号码RoomType varchar 客房类型Price float 客房价格Status int 客房状态CreateTime date 创建时间3.2 预订信息表字段名类型描述ReservationID int 预订号码CustomerID int 客户号码RoomID int 客房号码CheckInDate date 入住日期CheckOutDate date 退房日期3.3 入住信息表字段名类型描述CheckInID int 入住号码CustomerID int 客户号码RoomID int 客房号码CheckInDate date 入住日期3.4 账单信息表字段名类型描述BillID int 账单号码CustomerID int 客户号码RoomID int 客房号码TotalAmount float 总金额4. 用户界面设计用户界面是酒店管理系统与用户进行交互的重要环节。

C语言实现酒店管理系统

C语言实现酒店管理系统

C语言实现酒店管理系统这篇文章主要为大家详细介绍了C语言实现酒店管理系统,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下:源码如下:#include<bits/stdc++.h>#include<conio.h>#include <windows.h>#include<string.h>#include<time.h>#define NUM 1000 //控制房间个数int j;void LoginRoom();//登记房屋void SearchRoom();//搜寻房屋void ChangeRoom();//更换住房void OutRoom();//退房void save();//保存信息void load();//载入信息//struct Totalstruct Total{char Name[20];int Sex;int Age;char IDcard[18];int hour;int xx;int yy;int zz;};struct room{int RoomID;char Tel[11];long Price;int Sign;int feiyong;//struct Date Datesum;struct Total Totallist;}Room[NUM];// 将房间个数写入信息void LoginRoom() //登记,注册客房信息函数{int i,n,k;n=0;system("cls");printf(" 用户登记\n");for(k=0;k<=1000;k++){printf("请输入客房号:\n");scanf("%d",&i);if(Room[i-1].Sign==1){printf("对不起,该房间已入住,请重新输入。

酒店管理系统(c语言)

酒店管理系统(c语言)

附录1.源程序代码#include<stdio.h〉void search();int main(){int s;printf(”—--——--——-——---—--—---———-—--—\n”);printf(" && 长江大酒店欢迎您的光临&&\n");printf(” --—-—---——-——------——-——--——--\n”);printf(” 1。

进入2退出\n”);printf("请您输入您的选择:");scanf(”%d",&s);//输入选项前的数字if(s==1)//判断s是否为1search();elseprintf("抱歉,您的输入有误!\n”);return 0;}void search(){int p[18],q[3],a,b,c,x,y,z;printf("请选择您需要的服务号码:\n1。

预订房间2。

退订房间\n”);scanf(”%d”,&a);//输入服务号码if(a>2||a<1)//判断a是否为1或2{printf("抱歉,您的输入有误,请重新输入!\n”);}else switch(a){case 1://执行预订房间的操作{printf("请您输入您的身份证号码:\n”);scanf(”%d”,&p[18]);//输入身份证18位数字printf("您已成功登入预订系统!!\n");printf(”请您选择预订房间标准的号码:\n”);printf("1。

单人标准间/夜150元 2.双人标准间/夜200元\n3.豪华套房/夜300元 4.总统套房/夜500元\n”);scanf("%d",&b);//输入预订房间的种类switch(b){case 1://执行预订单人标准间的操作printf(”请输入预订天数:\n");scanf(”%d",&x);//输入预订天数printf(”客官需预交款%d元!\n”,x*150);//输出预交款金额printf("1。

酒店管理系统范文C语言

酒店管理系统范文C语言

#i n c l u d e<> #include<>#include<>#include<> 记入住\n"); printf("\t2.查询房间的入住情况\n");printf("\t3.查询当前费用\n"); printf("\t4.结账退房\n");printf("\t5.退出程序\n");}void hotel_execute();void hotel_select();void hotel_outhotel();void outsystem();void hotel_total();int main(void){system("color f1");init();while(1){Loop: hotelTitle();printf("\n 请选择:");j=scanf("%d",&k);if(j==0||k<1||k>5){printf("\n 输入错误。

\n\t 请输入所列出的选项。

\n\n 3 秒后刷新...Please Weit! Thanks\n");fflush(stdin);.请换房入住哈。

\n");}} .\n");}} .再会。

\n",x,y);}} .\n",duration); .system("pause");if(p>2){total=day*100;if(day==0) { total=100; }printf("\n 我们旅店是按包天计费的。

\n 若按小时,您需要付%f 元,但是现在你要付100 元(黑店哈哈)\n",total); 造酒店中的名牌....";int i,j;j=strlen(message);for(i=0;i<j;i++){printf("%c",message[i]);// sleep(30);//睡眠30 毫秒。

酒店管理系统代码

酒店管理系统代码

#include <windows.h>#include <dos.h>#include<stdio.h>#include<stdlib.h>#include<time.h>//-------------------------------------------------- 结构定义 ------------------------------------------typedefstructCheckinInformation{char name[10]; // 姓名int id; // 证件号introomType; // 房型intcountType; // 计费方式}CheckinInfo;typedefstructHotelRoom{introomType; // 房型introomNum; // 房号int checked; // 入住情况int price; // 房价}Room;typedefstructRoomOrder{CheckinInfo *checkinInfo; // 入住信息long date; // 入住时间Room * room; // 房间信息}Order;typedefstructHotelInfomation{intcheckinAmount; // 已入住房数intsingleRemainAmount; // 单人房剩余房数intdoubleRemainAmount; // 双人房剩余房数intbigRemainAmount; // 大床房剩余房数}HotelInfo;//-------------------------------- 枚举类型 ---------------------------enum {MainUI,HotelInfoUI,CheckinUI,CheckinResultUI,OrderUI,CheckOutUI,Exit};//GUIenum {Single,Double,Big};//Room Typeenum {Hour,Day};//countType//-------------------------------- 全局变量 --------------------------int GUI = MainUI;Order*orderList[100]; Room*roomList[100]; // 订单数组// 房间数组HotelInfo * hotelInfo = NULL;// 酒店房间信息//------------------------------- 函数声明 ---------------------------- voidinitiallizeRoomList();voidinsertToOrderList(Order * order);Room* getRoomByType(introomType);Order* getOrderByRoomNum(introomNum);voidshowMainUI();voidshowHotelInfoUI();voidshowCheckinUI();voidshowCheckinResultUI();voidshowOrderUI();voidshowCheckOutUI();//-------------------------------Main函数 ----------------------------void main() // 主函数{//初始化酒店房间信息hotelInfo = (HotelInfo *)malloc(sizeof(HotelInfo));hotelInfo ->singleRemainAmount = 20;hotelInfo ->doubleRemainAmount=40;hotelInfo ->bigRemainAmount=40;hotelInfo ->checkinAmount=0;//初始化房间列表initiallizeRoomList();//界面显示while(GUI != Exit){switch(GUI){caseMainUI:showMainUI();break; caseHotelInfoUI:showHotelInfoUI();break;caseCheckinUI:showCheckinUI();break;caseCheckinResultUI:showCheckinResultUI();break;caseOrderUI:showOrderUI();break;caseCheckOutUI:showCheckOutUI();break;default:break;}}}//------------------------------- 函数定义----------------------------voidinitiallizeRoomList(){//房间数组初始化,初始化的结果是让 roomList 的数组有 100 个 room 指针,而且设置了相应的值inti;Room*newRoom=NULL;for(i=0;i<20;i++){// 单人房房间信息初始化newRoom = ( Room* )malloc(sizeof(Room));roomList[i] = newRoom;roomList[i]->checked=0;roomList[i]->price=110;roomList[i]->roomNum=i+1;roomList[i]->roomType=Single;}for(i=20;i<60;i++){// 双人房房间信息初始化newRoom = ( Room* )malloc(sizeof(Room));roomList[i] = newRoom; roomList[i]->checked=0; roomList[i]->price=180; roomList[i]->roomNum=i+1;roomList[i]->roomType=Double;}// 大床房房间信息初始化for(i=60;i<100;i++){newRoom = ( Room* )malloc(sizeof(Room));roomList[i] = newRoom;roomList[i]->checked=0;roomList[i]->price=180;roomList[i]->roomNum=i+1;roomList[i]->roomType=Big;}}// 通过所选择的房型获取空房间,获取房间后将房间信息改为已入住,并减少相应房型的剩余房间数Room* getRoomByType(introomType){inti;switch(roomType){case Single:for(i=0;i<20;i++){if(roomList[i]->checked == 0){roomList[i]->checked=1;hotelInfo->singleRemainAmount -- ;hotelInfo->checkinAmount++;returnroomList[i];}}break;case Double:for(i=20;i<60;i++){if(roomList[i]->checked == 0){roomList[i]->checked=1;hotelInfo->doubleRemainAmount -- ;hotelInfo->checkinAmount++;returnroomList[i];}}break;case Big:for(i=60;i<100;i++){if(roomList[i]->checked == 0){roomList[i]->checked=1;hotelInfo->bigRemainAmount --;hotelInfo->checkinAmount++;returnroomList[i];}}break;}}//将订单放入订单列表voidinsertToOrderList(Order * order){inti;for(i = 0;i<100;i++){if(orderList[i] ==NULL ){orderList[i] = order;break;}}}//通过房号查询订单Order* getOrderByRoomNum(introomNum){inti;for(i=0;i<100;i++){if(orderList[i]->room->roomNum == roomNum){returnorderList[i]; }}}voidshowMainUI(){//显示主界面,并接受输入intchooseNum;system("cls");printf("\n\n========================== 酒店房间登记与计费管理管理系统=======================\t\n\n\n");printf("*\t\t\ t\t1.入住登记\t\t\t\t*\n");printf("*\t\t\t\t2. 查询入住情况\t\t\t*\n");printf("*\t\t\t\t3. 查询当前费用\t\t\t*\n");printf("*\t\t\t\t4. 结账退房\t\t\t\t*\n");printf("*\t\t\t\t5. 退出程序\t\t\t\t*\n\n\n");printf("\n\n========================== 酒店房间登记与计费管理管理系统 =======================\t\n\n\n");printf(" 请输入相应编号进入菜单 \t");//接受输入scanf("%d",&chooseNum);switch(chooseNum){case 1:GUI = HotelInfoUI;break;case 2:GUI = HotelInfoUI;break;case 3:GUI = OrderUI;break;case 4:GUI = OrderUI;break;case 5:专业资料整理Sleep(3000);GUI = Exit;break;default:break;专业资料整理}}voidshowHotelInfoUI(){intchooseNum;system("cls");printf("\n\n========================= 酒店入住情况查询菜单=======================\t\n\n\n\n");printf("*\t\t\t 入住房间数 : %d\t\t\t\t*\n", hotelInfo->checkinAmount);printf("*\t\t\t 剩余房间数 : \t");printf(" 单人房: %d\t\t*\n",hotelInfo->singleRemainAmount);printf("*\t\t\t\t\t 双人房: %d\t\t*\n",hotelInfo->doubleRemainAmount);printf("*\t\t\t\t\t 大床房: %d\t\t*\n\n",hotelInfo->bigRemainAmount);printf("\n\n========================= 酒店入住情况查询菜单=======================\t\n\n\n");printf(" 按 0 :返回\n");printf(" 按 1 : 登记入住 \n");scanf("%d",&chooseNum);switch(chooseNum){case 0:GUI = MainUI;break;case 1:GUI = CheckinUI;break;default:GUI = HotelInfoUI;break;}}voidshowCheckinUI(){Order * newOrder;Room* newRoom = NULL;//填写一个新的入住信息CheckinInfo * newCheckinInfo = NULL;专业资料整理introomTypeNum;intcountTypeNum;专业资料整理time_ttimep;system("cls");printf("\n\n=========================== 酒店入住登记菜单=========================\t\n\n\n");newCheckinInfo = ( CheckinInfo * )malloc(sizeof(CheckinInfo));printf("*\t\t 请输入姓名 :");scanf("%s", &(newCheckinInfo->name) );printf("*\t\t 请输入证件号 :");scanf("%d", &(newCheckinInfo->id) );printf("*\t\t 请选择入住房型 :\n");printf("\t\t\t1. 单人房 \n\t\t\t2. 双人房\n\t\t\t3. 大床房 \n"); scanf("%d",&(roomTypeNum));switch(roomTypeNum) // 通过输入的数字对应房型{case 1:newCheckinInfo->roomType = Single;break;case 2:newCheckinInfo->roomType = Double;break;case 3:newCheckinInfo->roomType = Big;break;default:newCheckinInfo->roomType = Single;break;}printf("*\ t\tprintf("\t \t\t1. 请选择计费方式:\n");按小时计费 ;\n\t\t\t2.按天数计费\n"); // 通过输入的数字对应计费方式scanf("%d",&countTypeNum);switch(countTypeNum){case 1:专业资料整理newCheckinInfo->countType = Hour;break;case 2:专业资料整理newCheckinInfo->countType = Day;break;}printf("\n\n=========================== 酒店入住登记菜单=========================\t\n\n\n");//生成一个新的订单newOrder = ( Order* )malloc(sizeof(Order));newOrder ->checkinInfo = newCheckinInfo;newOrder -> date = time(0);switch(newCheckinInfo->roomType){case Single:newRoom = getRoomByType(Single);break;case Double:newRoom=getRoomByType(Double);break;case Big :newRoom=getRoomByType(Big);break; // 通过房型获取房间}newOrder->room = newRoom; insertToOrderList(newOrder);print f(" 房间号为:%d\n",newOrder->room->roomNum);GUI = CheckinResultUI;}voidshowCheckinResultUI(){intchooseNum;printf("\n\n========================= 酒店入住登记确认菜单=======================\t\n\n\n");printf("\t\t\t************\t\t\t\t\n");printf("\t\t\t* 登记成功*\t\t\t\t\n");printf("\t\t\t************\t\t\t\t\n\n");printf("\n\n========================= 酒店入住登记确认菜单=======================\t\n\n\n");专业资料整理printf(" 按 0 :返回\n");scanf("%d",&chooseNum);专业资料整理switch(chooseNum){case 0:GUI = MainUI;break;default:GUI = CheckinResultUI;break;}}voidshowOrderUI(){introomNum;intchooseNum;int amount;Order * theOrder = NULL;system("cls");printf("\n\n========================= 酒店房间信息查询菜单=======================\t\n\n\n");printf(" 请输入房间号 :");scanf("%d",&roomNum);if (roomNum<0 || roomNum>100){printf("\n 输入有误请重新输入") ;GUI = OrderUI;}else{theOrder = getOrderByRoomNum(roomNum);printf(" 房型: ");switch(theOrder->room->roomType){case Single:printf(" 单人房 \n");break;case Double:printf(" 双人房 \n");break;case Big:printf(" 大床房 \n");break;}printf(" 计费方式: ");专业资料整理switch(theOrder->checkinInfo->countType ) {专业资料整理case Hour:printf(" 小时计费 \n");amount = (time(0) - theOrder->date) / 3600 +1;printf(" 已入住时间: %d 小时 \n",amount);break;case Day:printf(" 天计费 \n");amount = (time(0) - theOrder->date) / (3600*24) +1;printf(" 已入住时间: %d 天\n",amount);break;}printf(" 房价: %d\n",theOrder->room->price);printf(" 应支付: %d\n\n",amount * theOrder->room->price);printf("\n\n========================= 酒店房间信息查询菜单=======================\t\n\n\n");printf(" 按 0:返回 \n");printf(" 按 1:结账退房 \n");scanf("%d",&chooseNum);switch(chooseNum){case 0:GUI = MainUI;break;case 1:GUI = CheckOutUI;break;default:break;}}}voidshowCheckOutUI(){intchooseNum;printf("\n\n========================= 酒店结账退房确认菜单=======================\t\n\n\n");printf("\t\t\t\t************\t\t\t\t\n");printf("\t\t\t\t* 结账成功*\t\t\t\t\n");printf("\t\t\t\t************\t\t\t\t\n\n");printf("\n\n========================= 酒店结账退房确认菜单=======================\t\n\n\n");printf(" 按 0 :返回 "); scanf("%d",&chooseNum);switch(chooseNum) {case 0:GUI = MainUI;break;default:GUI = CheckOutUI;break;}}。

简易酒店管理系统代码

简易酒店管理系统代码

#include <stdio.h>#include <stdlib.h>#include <string.h>#include <time.h>//时间函数的定义struct tm *localtime(const time_t * timep);//时间的初始化char *wday[]={"星期天","星期一","星期二","星期三","星期四","星期五","星期六"}; time_t timep;struct tm *now;struct tm *after;// time(&timep);//酒店房间的定义struct house{char house_number[10];char house_shape[2];float house_price;int sum_person;// struct house *next;}h[10]={{"101","1",200.0,0},{"102","1",200.0,0},{"103","1",200.0,0},{"104","2",150.0,0},{"105","2",150.0,0},{"106","3",100.0,0},{"107","1",200.0,0},{"108","2",150.0,0},{"109","3",100.0,0},{"110","1",200.0,0}};{//住客姓名、性别、年龄、身份、身份证号码,房号,床号,入住日期、入住时间、离店日期、离店时间。

C语言酒店入住管理系统课设(附源码)

C语言酒店入住管理系统课设(附源码)

C语言酒店入住管理系统课设项目说明本系统基于C语言开发,适用于刚入门的C语言新手项目课设,开发软件采用VC++6.0开发,VS,DEV C++等均可运行。

(书生)项目运行截图代码界面截图完整源码#include<stdio.h>#include<stdlib.h>#include<time.h>#include<string.h>#include <conio.h>#define N 10#define HOURROOM 10#define NORMALROOM 288#define BIGROOM 388#define WORTHROOM 588#define GREATROOM 998struct room_message{int number; //房间号int people; //有无入住int floor; //楼层数(不同楼层房间类型不同)time_t time; //入住时间,无人住则置空}ROOM[100];struct administrator{char name[16];char password[16];int number;int age;int sex;}group[25];int TheUsingAdministrator;void BuildGroup(){ //建立密码文件FILE *fp=NULL;int a;char b[16]={"0"};if((fp=fopen("administrator.dat","r"))==NULL){ //创建文件,防止出错fp=fopen("administrator.dat","w");for(a=0;a<25;a++){strcpy(group[a].name,b);strcpy(group[a].password,b);group[a].number=a+1;group[a].sex=group[a].age=0;fwrite(&group[a],sizeof(struct administrator),1,fp);。

酒店管理及计费系统系统c语言代码

酒店管理及计费系统系统c语言代码
woundedincludeincludeincludedefine100这是房间的个数最多100个如果改动则改动100就可以structhotelcharname20
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define M 100//这是房间的个数最多100个,如果改动则改动100就可以
printf("\n\t\t\t请输入任意数字返回主界面!\n");
scanf("%d",&j);
system("cls");
goto L1;
break;
case 2:printf("请输入你要查询的房间号:");
scanf("%d",&q);
for(w=0;;w++)
{
if(q==worker[w].num2)
{
printf("姓名是:%s\n身份证:%s\n房间号:%d\n入住时间:%d\n入住天数:%d",worker[w].name,worker[w].shen,worker[w].num2,worker[w].num3,worker[w].num6);
break;
}
}
printf("\n\t\t\t请输入任意数字返回主界面!\n");
break;
}}Leabharlann printf("退订成功,路上慢走,祝您生活愉快!\n");
goto L1;
break;
case 5:system("cls");

酒店管理系统代码(C语言版)

酒店管理系统代码(C语言版)

#include <stdio.h>#include <stdlib.h>#include <string.h>//房间信息结构体struct Node{int Count; //指示该房间有多少个房客char nameOne[20]; //房客1的名字char nameTwo[20]; //房客2的名字int sexOne; //房客1的性别-1代表女,0代表没有,1代表男int sexTwo; //房客2的性别int roomNumber; //房间号}roomArray[5];//初始化房间数组void InitArray(){int i;for(i=0;i<5;i++){roomArray[i].roomNumber = 301+i;memset(roomArray[i].nameOne,0,20);memset(roomArray[i].nameTwo,0,20);roomArray[i].sexOne = 0;roomArray[i].sexTwo = 0;roomArray[i].Count = 0;}}void fun1() //旅客入住的操作{char name[20];int sex;int i;printf("\n输入入住旅客姓名和性别(空格隔开,1为男,-1为女):");scanf("%s %d",name,&sex);for(i=0;i<5;i++){{continue;}else if(roomArray[i].Count == 1){if(roomArray[i].sexOne != sex){continue;}strcpy(roomArray[i].nameTwo,name);roomArray[i].sexTwo = sex;roomArray[i].Count++;system("cls");printf("客人已经成功入住,在房间%d",roomArray[i].roomNumber);return;;}else{strcpy(roomArray[i].nameOne,name);roomArray[i].sexOne = sex;roomArray[i].Count++;system("cls");printf("客人已经成功入住,在房间%d",roomArray[i].roomNumber);return;;}}printf("无法入住,房间已经住满或者是没有适合的房间");}void fun2() //退房操作{int i;char name[20];printf("请输入要退房旅客的姓名:");scanf("%s",name);for(i=0;i<5;i++){if(strcmp(roomArray[i].nameOne,name) == 0){memset(roomArray[i].nameOne,0,20);roomArray[i].Count--;system("cls");printf("%s客人已经成功退房\n",name);return;}if(strcmp(roomArray[i].nameTwo,name) == 0){memset(roomArray[i].nameTwo,0,20);roomArray[i].sexTwo = 0;roomArray[i].Count--;system("cls");printf("%s客人已经成功退房\n",name);return;}}system("cls");printf("没有名为%s的客人,请检查输入的正确性!\n",name);}void fun3() //查询操作{int index;int i;char name[20];int number;int j;system("cls");printf("***************请选择要查询的种类***************\n");printf(" 1.所有房间入住信息显示\n");printf(" 2.按照姓名查询\n");printf(" 3.按照房号查询\n");scanf("%d",&index);if(index == 1){for( i=0;i<5;i++){printf("房间%d:",roomArray[i].roomNumber);if(roomArray[i].Count == 0){printf("没有客人入住\n");}else if(roomArray[i].Count == 1){if(roomArray[i].sexTwo == 0){printf("当前有1位客人-> %s,",roomArray[i].nameOne);if(roomArray[i].sexOne == 1)printf("性别:男");else if(roomArray[i].sexOne == -1)printf("性别:女");printf("\n");}else if(roomArray[i].sexOne == 0){printf("当前有1位客人-> %s,",roomArray[i].nameTwo);if(roomArray[i].sexTwo == 1)printf("性别:男");else if(roomArray[i].sexTwo == -1)printf("性别:女");printf("\n");}}else{//printf("当前有两个客人客人1:%s,性别%d 客人2:%s,性别%d \n",roomArray[i].nameOne,roomArray[i].sexOne,roomArray[i].nameTwo,roomArray[i].sexTwo);printf("当前有2位客人-> %s,",roomArray[i].nameOne);if(roomArray[i].sexOne == 1)printf("性别:男,");else if(roomArray[i].sexOne == -1)printf("性别:女,");printf(":%s,",roomArray[i].nameTwo);if(roomArray[i].sexTwo == 1)printf("性别:男,");else if(roomArray[i].sexOne == -1)printf("性别:女,");printf("\n");}}}else if(index == 2){printf("请输入你要查询房客的姓名:");scanf("%s",name);for(i=0;i<5;i++){if(strcmp(roomArray[i].nameOne,name) == 0 || strcmp(roomArray[i].nameTwo,name) == 0){printf("%s房客入住在房间%d!\n",name,roomArray[i].roomNumber);return;}}printf("没有找到该旅客的信息!");}else if(index == 3){printf("请输入你要查询的房间号:");scanf("%d",&number);j = number - 301;if(roomArray[j].Count == 0){printf("没有客人入住\n");}else if(roomArray[j].Count == 1){printf("当前有1位客人-> %s,性别%d!",roomArray[j].nameOne,roomArray[j].sexOne);}else{printf("当前有两个客人入住%s,性别%d %s,性别%d \n",roomArray[j].nameOne,roomArray[j].sexOne,roomArray[j].nameTwo,roomArray[j].sexTwo);}}}void show(){system("color 9f");printf("*******************请选择操作************************\n");printf(" 1.旅客入住\n");printf(" 2.旅客退房\n");printf(" 3.信息查询\n");printf(" 4.退出exit\n");printf("请输入你要选择的操作:");}int main(){int i= 100;InitArray();printf("*******************宾馆信息管理软件*******************\n");while(i != 4){printf("\n");show();scanf("%d",&i);switch(i){case 1:fun1();break;case 2:fun2();break;case 3:fun3();break;}}system("pause");return 0;}。

C语言课程设计--酒店房间登记与计费管理系统程序代码.doc

C语言课程设计--酒店房间登记与计费管理系统程序代码.doc

#i n c l u d e<s t d i o.h>#include<string.h> //在使用中要用到的字符串都包含在本文件中#include<stdlib.h> //exit()函数就包含在此文件中#define M 81int z[81]={0}; //定义一个数组存放使用的房间的标记的信息,且初始化为0int j,s; //定义两个全局变量FILE *fp; //定义一个指向文件的指针变量struct date{int month;int day;int year;}final;struct hotel{int price;int room_ID;struct client{char name[20];int sex;int age;char ID_card[20];int count;struct date start;}personal;}room[M]; //定义全局结构体变量,且里面又调用两个结构体 //声明刷新函数fflush( fp),且指向指针变量指向的位置void save();void search_situ( ); //声明查看客房入住情况函数void regist_infor( ); //声明客房登记入住函数void modify_infor( ); //声明客房信息修改函数函数void modify_one( ); //声明修改客房信息函数中的修改个人函数void modify_hotel( ); //声明修改客房信息函数中的修改客房函数void disp_money( ); //声明显示入住费用函数int main(){int menu(); //声明主菜单函数void print_star();void print_message();printf("\n\n\n\n\n");print_star();printf("\n");print_message();printf("\n");print_star();menu(); //把主菜单用函数来实现save();return 0;}void print_star(){int i;for(i=1;i<30;i++)printf("\t*");}void print_message(){printf("\t\t\t\t欢迎入住皇家酒店\n");}menu(){int n;do{printf("\n");printf("\t\t*********************菜单********************\n\n\n");printf("\t\t\t\t1:查看客房入住情况\n\n\n");printf("\t\t\t\t2:登记入住信息\n\n\n");printf("\t\t\t\t3:修改客房信息\n\n\n");printf("\t\t\t\t4:显示入住费用\n\n\n");printf("\t\t\t\t5:退出\n\n\n");printf("\t\t\t\t6:返回\n\n\n");printf("\t\t*********************菜单********************\n"); printf("\n\n\t\t\t 请选择输入选项[1\\2\\3\\4\\5\\6]:\n");scanf("%d",&n);while(n<1||n>6){printf("请重新输入选项!");scanf("%d",&n);}switch(n){case 1:search_situ();break; //调用查看函数case 2:regist_infor();break; //调用登记函数case 3:modify_infor();break; //调用修改函数case 4:disp_money();break; //调用显示入住费用函数case 5:exit(0);case 6:break;}}while(n!=6);scanf("%d",&n);return 0;}void search_situ( ) //查看函数{int g,count=0;for(g=1;g<=80;g++){if(z[g]==0)++count;elseif(z[g]==1)printf("\n正在使用的房间号:%d",g);}printf("\n\n未使用的房间数:%d",count); //通过循环输出未使用的房间数 printf("\n\n");printf("\n请输入需查询的房间号:\n"); //查询输入的房间号的信息,且输出该房间的相关信息scanf("%d",&s);if(z[s]==1){printf("姓名:%s",room[s]);printf("\n性别(其中:1表示男,2表示女!):%d",room[s].personal.sex);printf("\n年龄:%d",room[s].personal.age);printf("\n身份证号:%s",room[s].personal.ID_card);printf("\n入住年份:%d",room[s].personal.start.year);printf("月:%d",room[s].personal.start.month);printf("日:%d",room[s].personal.start.day);printf("\n房间号:%d",room[s].room_ID);printf("\n客房单价:%d",room[s].price);printf("\n入住人数:%d",room[s].personal.count);menu();}elseprintf("该房间未被使用!");save(); //调用保存函数}void regist_infor( ) // 登记函数{printf("请输入登记相关信息:\n");printf("\n房间号:");scanf("%d",&j);room[j].room_ID=j;printf("\n姓名:");scanf("%s",&room[j]);printf("\n性别(其中:1表示男,2表示女!):");scanf("%d",&room[j].personal.sex);printf("\n年龄:");scanf("%d",&room[j].personal.age);printf("\n身份证号:");scanf("%s",&room[j].personal.ID_card);printf("\n入住年份:");scanf("%d",&room[j].personal.start.year);printf("月:");scanf("%d",&room[j].personal.start.month);printf("日:");scanf("%d",&room[j].personal.start.day);printf("\n客房单价:");scanf("%d",&room[j].price);printf("请输入入住人数\n");scanf("%d",&room[j].personal.count);z[j]=1; //标记使用的房间为1save();}void modify_infor( ) //修改函数{int r,m;do{printf("\t\t\t *******************菜单******************\n\n\n");printf("\t\t\t\t\t 1:修改客户信息\n\n\n");printf("\t\t\t\t\t 2:修改客房信息\n\n\n");printf("\t\t\t\t\t 3:menu()\n\n\n");printf("\t\t\t\t\t4:退出\n\n\n");printf("\t\t\t *****************************************\n\n\n");printf("\t\t\t 请选择输入选项[1\\2\\3\\4]:\n");scanf("%d",&m);if(m<1||m>3){r=1;getchar();}else r=0;}while(r==1);switch(m){case 1:modify_one();break;case 2:modify_hotel();break;case 3:menu();case 4:exit(0);}save();}void modify_one() //修改个人信息函数{int q;char a[20];printf("\n请选择您要修改的个人选项\n");printf("1:姓名 2:性别(其中:1表示男,2表示女!) 3:年龄 4:身份证号 5:入住年份 6:入住月份 7入住日 8:入住人数\n");printf("\t请选择输入选项[1\\2\\3\\4\\5\\6\\7\\8]:\n\b\b");scanf("%d",&q);switch(q){int t,p;char k;case 1:printf("请输入新名字\n");for(t=0;t<20;t++)scanf("%s",&a[t]);strcpy(room[j],a);break;case 2:printf("请选择新性别(其中:1表示男,2表示女!)\n");scanf("%d",&k);room[j].personal.sex=k;break;case 3:printf("请输入新年龄\n");scanf("%d",&p);room[j].personal.age=p;break;case 4:printf("请输入新身份证号\n");scanf("%d",&p);room[j].personal.ID_card[20]=p;break;case 5:printf("请输入新年份\n");scanf("%d",&p);room[j].personal.start.year=p;break;case 6:printf("请输入新月份\n");scanf("%d",&p);room[j].personal.start.month=p;break;case 7:printf("请输入新日子\n");scanf("%d",&p);room[j].personal.start.day=p;break;case 8:printf("请输入新入住人数\n");scanf("%d",&p);room[j].personal.count=p;break;}menu();}void modify_hotel() //修改客房信息函数{int l;printf("\n\t\t\t\t请选择您要修改的客房信息\n\n");printf("\t\t\t\t1:房间号\n\n \t\t\t\t2:客房单价\n\n \t\t\t\t3:入住人数\n\n \t\t\t\t4:返回\n\n");printf("\t\t\t请选择输入选项[1\\2\\3\\4]:\n\b\b");scanf("%d",&l);switch(l){case 1:printf("请输入旧房号\n");scanf("%d",&j);printf("请输入新房号\n");scanf("%d",&s);strcpy(room[s],room[j]);room[s].personal.sex=room[j].personal.sex; room[j].personal.sex=0;room[s].personal.age=room[j].personal.age; room[j].personal.age=0;strcpy(room[s].personal.ID_card,room[j].personal.ID_card);room[s].personal.start.year=room[j].personal.start.year;room[j].personal.start.year=0;room[s].personal.start.month=room[j].personal.start.month;room[j].personal.start.month=0;room[s].personal.start.day=room[j].personal.start.day;room[j].personal.start.day=0;room[s].room_ID=s;room[s].price=room[j].price;room[s].personal.count=room[j].personal.count;z[s]=1; z[j]=0; break;case 2:printf("请输入房号\n");scanf("%d",&s);printf("请输入新单价\n");scanf("%d",&s);room[s].price=s;break;case 3:printf("请输入房号\n");scanf("%d",&s);printf("请输入新入住人数\n");scanf("%d",&s);room[s].personal.count=s;break;case 4:break;}save();menu();}void disp_money( ) //显示入住费用函数{int i,sum;printf("请输入房间号;\n");scanf("%d",&room[j].room_ID);printf("\n入住年份:%d",room[j].personal.start.year);printf("月:%d",room[j].personal.start.month);printf("日:%d",room[j].personal.start.day);printf("房间单价为:");printf("%d",room[j].price);printf("\n请输入退房时间:\n");printf("请输入年份:");scanf("%d",&final.year);printf("请输入月份:");scanf("%d",&final.month);printf("请输入日:");scanf("%d",&final.day);printf("\n请输入住房天数:\n");scanf("%d",&i);sum=room[j].price*i;printf("总费用sum=%d\n",sum);save();menu();}void save() //保存函数{FILE *fp;int i;if((fp=fopen("客房管理.txt","w+"))==NULL) //打开输出文件"客房管理.txt" {printf("cannot open file\n");exit(0);}for(i=0;i<M;i++){if(fwrite((&room[i]), sizeof(room[M]),1,fp)!=1)printf("file write error\n");fflush(fp);}fclose(fp); //关闭文件}。

酒店管理系统代码

酒店管理系统代码

#include 〈windows。

h>#include 〈dos。

h〉#include<stdio.h>#include〈stdlib。

h〉#include〈time。

h>//-—-———--——-————————-———--———---—---—-———--—-—-—-——结构定义-—--—-—-—-——---——--——-——-----—-——-—---—-——typedef struct CheckinInformation{char name[10];//姓名int id;//证件号int roomType; //房型int countType; //计费方式}CheckinInfo;typedef struct HotelRoom{int roomType;//房型int roomNum; //房号int checked; //入住情况int price;//房价}Room;typedef struct RoomOrder{CheckinInfo *checkinInfo; //入住信息long date;//入住时间Room *room; //房间信息}Order;typedef struct HotelInfomation{int checkinAmount;//已入住房数int singleRemainAmount; //单人房剩余房数int doubleRemainAmount;//双人房剩余房数int bigRemainAmount;//大床房剩余房数}HotelInfo;//-——--—-——-————--——------—————--—枚举类型—-—-—---————--—---—————--—-enum {MainUI,HotelInfoUI,CheckinUI,CheckinResultUI,OrderUI,CheckOutUI,Exit};//GUI enum {Single,Double,Big};//Room Typeenum {Hour,Day};//countType//——-————-——-———-—---—-————-—-----全局变量—--—--—————-———--——-—-————int GUI = MainUI;Order* orderList[100];//订单数组Room* roomList[100];//房间数组HotelInfo *hotelInfo = NULL;//酒店房间信息//-———-———-———--—-----——-------——函数声明——--——--—-----—--—---—--—-——void initiallizeRoomList();void insertToOrderList(Order * order);Room* getRoomByType(int roomType);Order*getOrderByRoomNum(int roomNum);void showMainUI();void showHotelInfoUI();void showCheckinUI();void showCheckinResultUI();void showOrderUI();void showCheckOutUI();//—————-—-——-———--———-—-—---——-—-Main函数-—--———---—-—-—--—————---———void main() //主函数{//初始化酒店房间信息hotelInfo = (HotelInfo *)malloc(sizeof(HotelInfo));hotelInfo -〉singleRemainAmount = 20;hotelInfo -〉doubleRemainAmount=40;hotelInfo —> bigRemainAmount=40;hotelInfo —〉checkinAmount=0;//初始化房间列表initiallizeRoomList();//界面显示while(GUI != Exit){switch(GUI){case MainUI:showMainUI();break;case HotelInfoUI:showHotelInfoUI();break;case CheckinUI:showCheckinUI();break;case CheckinResultUI:showCheckinResultUI();break;case OrderUI:showOrderUI();break;case CheckOutUI:showCheckOutUI();break;default:break;}}}//--————--—-——-—-—--—————------—-函数定义--——-------——--———-——--——-—-void initiallizeRoomList(){//房间数组初始化,初始化的结果是让roomList的数组有100个room指针,而且设置了相应的值int i;Room*newRoom=NULL;for(i=0;i〈20;i++)//单人房房间信息初始化{newRoom = (Room* )malloc(sizeof(Room));roomList[i] = newRoom;roomList[i]->checked=0;roomList[i]—>price=110;roomList[i]—>roomNum=i+1;roomList[i]-〉roomType=Single;}for(i=20;i〈60;i++)//双人房房间信息初始化{newRoom = (Room* )malloc(sizeof(Room));roomList[i]= newRoom;roomList[i]-〉checked=0;roomList[i]->price=180;roomList[i]-〉roomNum=i+1;roomList[i]—>roomType=Double;}for(i=60;i<100;i++)//大床房房间信息初始化{newRoom = ( Room* )malloc(sizeof(Room));roomList[i]= newRoom;roomList[i]—>checked=0;roomList[i]—>price=180;roomList[i]—>roomNum=i+1;roomList[i]—〉roomType=Big;}}//通过所选择的房型获取空房间,获取房间后将房间信息改为已入住,并减少相应房型的剩余房间数Room*getRoomByType(int roomType){int i;switch(roomType){case Single:for(i=0;i<20;i++){if(roomList[i]->checked == 0){roomList[i]-〉checked=1;hotelInfo-〉singleRemainAmount —— ;hotelInfo—>checkinAmount++;return roomList[i];}}break;case Double:for(i=20;i〈60;i++){if( roomList[i]—>checked == 0){roomList[i]-〉checked=1;hotelInfo—>doubleRemainAmount -— ;hotelInfo->checkinAmount++;return roomList[i];}}break;case Big:for(i=60;i<100;i++){if( roomList[i]-〉checked == 0){roomList[i]—>checked=1;hotelInfo—〉bigRemainAmount —-;hotelInfo->checkinAmount++;return roomList[i];}}break;}}//将订单放入订单列表void insertToOrderList(Order *order){int i;for( i = 0;i<100;i++){if( orderList[i] ==NULL ){orderList[i] = order;break;}}}//通过房号查询订单Order* getOrderByRoomNum(int roomNum){int i;for(i=0;i<100;i++){if( orderList[i]-〉room—>roomNum == roomNum){return orderList[i];}}}void showMainUI(){//显示主界面,并接受输入int chooseNum;system(”cls”);printf(”\n\n==========================酒店房间登记与计费管理管理系统=======================\t\n\n\n”);printf(”*\t\t\t\t1。

C语言实现简单酒店管理系统

C语言实现简单酒店管理系统

C语⾔实现简单酒店管理系统本⽂实例为⼤家分享了C语⾔实现酒店管理系统的具体代码,供⼤家参考,具体内容如下⼀、问题描述系统应具有以下主要功能:登记⼊住:从键盘输⼊住信息:房间层数,房间号码等;查询⼊住情况,查询当前费⽤,退房、退出系统等功能。

⼆、基本要求(1)、登记⼊住。

可以输⼊多个信息,实现本系统数据的初始化。

(2)、列出所有的⼊住情况,⽤于顾客查询以及办理⼊住⼿续。

(3)、查询当前费⽤:显⽰顾客实时费⽤,便于顾客查询和退房时进⾏付费。

(4)、退房:办理退房⼿续,修改系统内信息,将此顾客的住房置空。

(5)、退出系统:对此次操作中信息的增删改后的数据写⼊⽂件中,保存后退出。

#include<stdio.h>#include<stdlib.h>#include<time.h> //调⽤系统的时间,通过时间的增减计算费⽤#include<string.h>#include<windows.h>#define N 10#define HOURROOM 10#define NORMALROOM 120#define BIGROOM 300#define WORTHROOM 500#define GREATROOM 800struct room_message{int number; //房间号int people; //有⽆⼊住int floor; //楼层数(不同楼层房间类型不同)time_t time; //⼊住时间,⽆⼈住则置空}ROOM[100];void BuildRoom(){ //创建房间的函数,对系统进⾏数据的初始化FILE *fp=NULL;int i,j;if((fp=fopen("roommessage.dat","r"))==NULL){fp=fopen("roommessage.dat","w");for(i=0;i<N;i++){for(j=0;j<N;j++){ROOM[i* 10+j].number= j;ROOM[i* 10+j].floor= i;ROOM[i* 10+j].people= 0;ROOM[i* 10+j].time= 0;fwrite(&ROOM[i* 10+j],sizeof(struct room_message),1,fp);}}}else {for(i=0;i<N;i++){for(j=0;j<N;j++){fread(&ROOM[i* 10+j],sizeof(struct room_message),1,fp);}}}fclose(fp);}void Printpay(int floor,int room,int fee,int people){ //打印所需费⽤,根据时间计算费⽤time_t time1,time2;int a;time1 = ROOM[floor*10+room].time;time2 = time(NULL);if(people==0){printf("该房间没有⼈\n");}else {if(floor<2){a = ((time2-time1)/3600)+1;printf("该房间的费⽤为%d元\n",a*fee);}else{a=(((time2-time1)/3600)/24)+1;printf("该房间的费⽤为%d元\n",a*fee);}}}void CheckOut(){ //退房函数,引⽤计算费⽤函数,并更改⼊住情况int roomnuber,choose,a,b,floor,room,fee;FILE *fp=NULL;do{printf("\n请输⼊您想退房的房间的房间号:");scanf("%d",&roomnuber);floor=(roomnuber / 100) - 1;room=roomnuber%100;floor = (roomnuber/100)-1 ;room = (roomnuber%100)-1;if(floor>9||floor<0||room<0||room>9){printf("您的输⼊有误,请重新在1-9之间输⼊\n");}}while(floor>9||floor<0||room<0||room>9);printf("您要退的房间号为%d,它是",roomnuber);if(floor==0||floor==1){printf("钟点房\n");fee=HOURROOM;}if(floor==2||floor==3){printf("标准间\n");fee=NORMALROOM;}if(floor==4||floor==5){printf("商务间\n");fee=BIGROOM;}if(floor==6||floor==7){printf("⾏政套房\n");fee=WORTHROOM;}if(floor==8||floor==9){printf("豪华套房\n");fee=GREATROOM;}do{printf("\n您是否确定要退房。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
return;
}
}
printf("没有找到该旅客的信息!");
}
else if(index == 3)
{
printf("请输入你要查询的房间号:");
scanf("%d",&number);
j = number - 301;
if(roomArray[j].Count == 0)
{
printf("没有客人入住\n");
{
memset(roomArray[i].nameOne,0,20);
roomArray[i].sexOne = 0;
roomArray[i].Count--;
system("cls");
printf("%s客人已经成功退房\n",name);
return;
}
if(strcmp(roomArray[i].nameTwo,name) == 0)
printf(" 4.退出 exit\n");
printf("请输入你要选择的操作: ");
}
int main()
{
int i= 100;
InitArray();
printf("*******************宾馆信息管理软件*******************\n");
while(i != 4)
{
memset(roomArray[i].nameTwo,0,20);
roomArray[i].sexTwo = 0;
roomArray[i].Count--;
system("cls");
printf("%s客人已经成功退房\n",name);
return;
}
}
system("cls");
printf("没有名为%s的客人,请检查输入的正确性!\n",name);
memset(roomArray[i].nameOne,0,20);
memset(roomArray[i].nameTwo,0,20);
roomArray[i].sexOne = 0;
roomArray[i].sexTwo = 0;
roomArray[i].Count = 0;
}
}
void fun1() //旅客入住的操作
{
printf("\n");
show();
scanf("%d",&i);
switch(i)
{
case 1:
fun1();
break;
case 2:
fun2();
break;
case 3:
fun3();
break;
}
}
system("pause");
return 0;
}
printf(" 2.按照姓名查询\n");
printf(" 3.按照房号查询\n");
scanf("%d",&index);
if(index == 1)
{
for( i=0;i<5;i++)
{
printf("房间%d:",roomArray[i].roomNumber);
if(roomArray[i].Count == 0)
if(roomArray[i].sexTwo == 1)
printf("性别:男,");
else if(roomArray[i].sexOne == -1)
printf("性别:女,");
printf("\n");
}
}
}
else if(index == 2)
{
printf("请输入你要查询房客的姓名:");
scanf("%s",name);
for(i=0;i<5;i++)
{
if(strcmp(roomArray[i].nameOne,name) == 0 || strcmp(roomArray[i].nameTwo,name) == 0)
{
printf("%s房客入住在房间%d!\n",name,roomArray[i].roomNumber);
}
}
}
void show()
{
system("color 9f");
printf("*******************请选择操作************************\n");
printf(" 1.旅客入住\n");
printf(" 2.旅客退房\n");
printf(" 3.信息查询\n");
return;;
}
}
printf("无法入住,房间已经住满或者是没有适合的房间");
}
void fun2() //退房操作
{
int i;
char name[20];
printf("请输入要退房旅客的姓名: ");
scanf("%s",name);
for(i=0;i<5;i++)
{
if(strcmp(roomArray[i].nameOne,name) == 0)
if(roomArray[i].sexTwo == 1)
printf("性别:男");
else if(roomArray[i].sexTwo == -1)
printf("性别:女");
printf("\n");
}
}
else
{
//printf("当前有两个客人 客人1: 姓名%s,性别%d 客人2: 姓名%s,性别%d \n",roomArray[i].nameOne,roomArray[i].sexOne,roomArray[i].nameTwo,roomArray[i].sexTwo);
printf("当前有2位客人-> 姓名%s,",roomArray[i].nameOne);
if(roomArray[i].sexOne == 1)
printf("性别:男,");
else if(roomArray[i].sexOne == -1)
printf("性别:女,");
printf("姓名:%s,",roomArray[i].nameTwo);
int sexOne; //房客1的性别 -1代表女,0代表没有,1代表男
int sexTwo; //房客2的性别
int roomNumber; //房间号
}roomArray[5];
//初始化房间数组
void InitArray()
{
int i;
for(i=0;i<5;i++)
{
roomArray[i].roomNumber = 301+i;
}
else if(roomArray[j].Count == 1)
{
printf("当前有1位客人-> 姓名%s,性别%d!",roomArray[j].nameOne,roomArray[j].sexOne);
}
else
{
printf("当前有两个客人入住 姓名%s,性别%d 姓名%s,性别%d \n",roomArray[j].nameOne,roomArray[j].sexOne,roomArray[j].nameTwo,roomArray[j].sexTwo);
printf("性别:男");
else if(roomArray[i].sexOne == -1)
printf("性别:女");
printf("\n");
}
else if(roomArray[i].sexOne == 0)
{
printf("当前有1位客人-> 姓名%s,",roomArray[i].nameTwo);
{
if(roomArray[i].sexOne != sex)
{
continue;
}
strcpy(roomArray[i].nameTwo,name);
roomArray[i].sexTwo = sex;
roomArray[i].Count++;
system("cls");
printf("客人已经成功入住,在房间%d",roomArray[i].roomNumber);
}
void fun3() //查询操作
{int index; Nhomakorabeaint i;
char name[20];
int number;
int j;
system("cls");
printf("***************请选择要查询的种类***************\n");
printf(" 1.所有房间入住信息显示\n");
#include <stdio.h>
相关文档
最新文档