请高手帮忙用C语言做一个酒店管理系统

发布时间:2024-05-11 21:13 发布:上海旅游网

问题描述:

要求很简单,只需要有最基本的要求:洒店住房管理:客户登记住房退房功能.住房管理,只需要普通的C语言程序,每一步都写清楚原理,谢谢请C语言高手帮一帮忙有的发到12315vinner@163.com谢谢
写得好的继续加分!

问题解答:

////////////////////////////
//Hotel manager system
//Design by WongSwoon
//08.11.9
////////////////////////////
#include<stdio.h>
#include<string.h>
#include<time.h>

//////////////////////////
struct Customer{
char name[10];
int id;
int tel;
int roomnum;
struct tm time;
}Customer[5][301];
//////////////////////////

struct Room{
int price;
int num;
int remain_num;
}room[5];

///////////////////////////
void InitRoom_Customer()
{
int i,j;
room[1].price=2000;
room[1].num=room[1].remain_num=5;
room[2].price=1000;
room[2].num=room[2].remain_num=100;
room[3].price=700;
room[3].num=room[3].remain_num=300;
room[4].price=400;
room[4].num=room[4].remain_num=200;
for(i=1;i<=4;i++)
for(j=1;j<=room[i].num;j++)
{
strcpy(Customer[i][j].name,"NULL");
Customer[i][j].id=0;
Customer[i][j].tel=0;
Customer[i][j].roomnum=1000*i+j;
Customer[i][j].time.tm_mon=1;
Customer[i][j].time.tm_mday=1;
}
}

///////////////////////////////////
int Isempty(struct Customer c)
{
if(!strcmp(c.name,"NULL"))
return 1;
else
return 0;
}

//////////////////////////////////
void OrderRoom(char c)
{
int i,n;
printf("roomnumber\tname\tID\ttel-num\ttime\n");

switch (c)
{
case 'a':
{
if(room[1].remain_num==0)
printf("Rooms has all been full of\n");
for(i=1;i<=room[1].num;i++)
printf("%d\t\t%s\t%d\t%d\t%d.%d\n",Customer[1][i].roomnum,Customer[1][i].name,
Customer[1][i].id,Customer[1][i].tel,Customer[1][i].time.tm_mon,Customer[1][i].time.tm_mday);

printf("Select the roomnumber and input the information:");
scanf("%d",&n);
for(i=1;i<=room[1].num;i++)
if(Customer[1][i].roomnum==n&&Isempty(Customer[1][i]))
break;
scanf("%s%d%d%d.%d",Customer[1][i].name,&Customer[1][i].id,
&Customer[1][i].tel,&Customer[1][i].time.tm_mon,&Customer[1][i].time.tm_mday);
room[1].remain_num--;

}break;

case 'b':

{
if(room[2].remain_num==0)
printf("Rooms has all been full of\n");
for(i=1;i<=room[2].num;i++)
printf("%d\t\t%s\t%d\t%d\t%d.%d\n",Customer[2][i].roomnum,Customer[2][i].name,
Customer[2][i].id,Customer[2][i].tel,Customer[2][i].time.tm_mon,Customer[2][i].time.tm_mday);

printf("Select the roomnumber and input the information:");
scanf("%d",&n);

for(i=1;i<=room[2].num;i++)
if(Customer[2][i].roomnum==n&&Isempty(Customer[2][i]))
break;

scanf("%s%d%d%d.%d",Customer[2][i].name,&Customer[2][i].id,
&Customer[2][i].tel,&Customer[2][i].time.tm_mon,&Customer[2][i].time.tm_mday);
room[2].remain_num--;
}break;

case 'c':
{
if(room[3].remain_num==0)
printf("Rooms has all been full of\n");
for(i=1;i<=room[3].num;i++)
printf("%d\t\t%s\t%d\t%d\t%d.%d\n",Customer[3][i].roomnum,Customer[3][i].name,
Customer[3][i].id,Customer[3][i].tel,Customer[3][i].time.tm_mon,Customer[3][i].time.tm_mday);

printf("Select the roomnumber and input the information:");
scanf("%d",&n);

for(i=1;i<=room[3].num;i++)
if(Customer[3][i].roomnum==n&&Isempty(Customer[3][i]))
break;

scanf("%s%d%d%d.%d",Customer[3][i].name,&Customer[3][i].id,
&Customer[3][i].tel,&Customer[3][i].time.tm_mon,&Customer[3][i].time.tm_mday);
room[3].remain_num--;
}break;

case 'd':
{
if(room[4].remain_num==0)
printf("Rooms has been full of\n");
for(i=1;i<=room[4].num;i++)
printf("%d\t\t%s\t%d\t%d\t%d.%d\n",Customer[4][i].roomnum,Customer[4][i].name,
Customer[4][i].id,Customer[4][i].tel,Customer[4][i].time.tm_mon,Customer[4][i].time.tm_mday);

printf("Select the roomnumber and input the information:");
scanf("%d",&n);

for(i=1;i<=room[4].num;i++)
if(Customer[4][i].roomnum==n&&Isempty(Customer[4][i]))
break;

scanf("%s%d%d%d.%d",Customer[4][i].name,&Customer[4][i].id,
&Customer[4][i].tel,&Customer[4][i].time.tm_mon,&Customer[4][i].time.tm_mday);
room[4].remain_num--;
}break;
}

}

//////////////////////////
void FindCustomer()
{
char c;
int i,j,flag;
flag=0;
printf("enter the customer's name\n");
scanf("%s",&c);

for(i=4;i>=1;i--)

{
for(j=1;j<=room[i].num;j++)
if(!strcmp(Customer[i][j].name,&c))
{
flag=1;
break;
}
if(flag)
break;

}

if(i==0)
printf("This gay is not found!\n");
else
{
printf("The Customer's info\n");
printf("roomnumber\tname\tID\ttel-num\ttime\n");
printf("%d\t\t%s\t%d\t%d\t%d.%d\n",Customer[i][j].roomnum,
Customer[i][j].name,Customer[i][j].id,Customer[i][j].tel,
Customer[i][j].time.tm_mon,Customer[i][j].time.tm_mday);
}

}

///////////////////////////////////
struct Customer * Find_With_RoomKey(int n)
{
/* int i,j,flag;
flag=0;

for(i=4;i>=1;i--)
{
for(j=1;j<=room[i].num;j++)
if(Customer[i][j].roomnum==n)
{
flag=1;
break;
}
if(flag)
break;
}

return &Customer[i][j];*/
return &Customer[n/1000][n%1000];//Hash method better!
}

//////////////////////////////////
long Checkout()
{
struct tm nowtime;
long sum,s_m,s_d;
int n;
printf("Input nowtime\n");
scanf("%d.%d",&nowtime.tm_mon,&nowtime.tm_mday);
printf("Enter the roomnumber\n");
scanf("%d",&n);
Find_With_RoomKey(n);
if(nowtime.tm_mday>Find_With_RoomKey(n)->time.tm_mday)
{
s_d=nowtime.tm_mday-Find_With_RoomKey(n)->time.tm_mday;
s_m=nowtime.tm_mon-Find_With_RoomKey(n)->time.tm_mon;
}
else
{
s_d=nowtime.tm_mday-Find_With_RoomKey(n)->time.tm_mday+31;
s_m=nowtime.tm_mon-Find_With_RoomKey(n)->time.tm_mon-1;
}

printf("The Room-%d Customer's info\n",Find_With_RoomKey(n)->roomnum);

printf("%d\t\t%s\t%d\t%d\t%d.%d\n",Find_With_RoomKey(n)->roomnum,
Find_With_RoomKey(n)->name,Find_With_RoomKey(n)->id,Find_With_RoomKey(n)->tel,
Find_With_RoomKey(n)->time.tm_mon,Find_With_RoomKey(n)->time.tm_mday);
sum=room[Find_With_RoomKey(n)->roomnum/1000].price*(s_m*31+s_d-2);
room[Find_With_RoomKey(n)->roomnum/1000].remain_num++;
strcpy(Find_With_RoomKey(n)->name,"NULL");
Find_With_RoomKey(n)->id=0;
Find_With_RoomKey(n)->roomnum=0;
Find_With_RoomKey(n)->tel=0;
Find_With_RoomKey(n)->time.tm_mon=1;
Find_With_RoomKey(n)->time.tm_mday=1;
return sum;
}
////////////////////////////////////////////

void Evaluate()
{
float rate;
rate=(float)(1.0-(float)( room[1].remain_num+room[2].remain_num+room[3].remain_num+room[4].remain_num)/
(room[1].num + room[2].num + room[3].num + room[4].num) );
//printf("%f",rate);
if( rate>0.8)
printf("★★★ Perfect\n");
else if(rate>0.6)
printf("★★☆ Good\n");
else
printf("★☆☆ Bad\n");
}

///////////////////////////////

void InitCmd()
{
int select;
printf("\t---------宾馆管理系统v1.0 A Hotel Managerment System-----------\n");
printf("\t\t订房-1\t查询顾客-2\t退房-3\t每日评估-4\n");

scanf("%d",&select);
switch(select)
{
char ch;
case 1:
printf("总统套房 a \n");
printf("豪华间 b \n");
printf("标准双人间 c \n");
printf("标准单人间 d \n");
printf("请选择房间类型 \n");
getchar();
scanf("%c",&ch);
OrderRoom(ch);
break;

case 2:
FindCustomer();
break;

case 3:
printf("The total cash is %ld YuanRMB\n",Checkout());
printf("Checkout the room successfully!\n");
break;
case 4:
Evaluate();

}
}

//////////////////////////////
int main()
{

InitRoom_Customer();
while(1)
InitCmd();
}

希望不大……

估计得花钱买

在这个经济社会里谁还会免费的帮人家出这么大的力啊?你那酒店管理系统要求再简单也要花时间啊!再说你要它的原理,这不是要人家的知识产权吗?也许人家开发出来把软件打包给你还有可能。

每一步都要写清楚原理?
是想拿去交的吗?
50分?
太少.
加分就写.

热点新闻