C语言课程设计酒店管理程序

C语言课程设计酒店管理程序,第1张

没有时间写,只有一点,朋友给的!

酒店管理

#include<stdio.h>

void xx()

void search()

main()

{ int f

printf(" ▲***********************▲\n")

printf(" △ 欢迎来到XXX饭店△\n")

printf(" ▲************************▲\n")

printf("1.进入. 2退出.\n")

scanf("%d",&f)

if(f==1)

search()

else

printf("输入错误")

}

void search()

{

int d[15],g[3],a,b,c,x,y,h

printf("请选袭山择您需要的号码:\n1.预定房间\n2.退定房间\n")

scanf("%d",&a)

if(a>3 || a<1)

{printf("您输入有误请您重试!\n")

}

else switch(a)

{ case 1:

{ printf("请您输入您的身份z号码\n")

scanf("%d",&d[15])

printf("您已登陆成功^-^\n")

printf("请您选择退定种类:\n")

printf("1.单人间/夜150元\n2.双人间/夜200元\n3.标准间/夜300元\n4.总统套房/夜600元\n")

scanf("%d",&b)

switch(b)

{ case 1:printf("请输入预定天数\n")

scanf("%d"虚稿,&x)

printf("请预交款为拍誉中%d元\n",x*150)

printf("1.确定 2.返回")

scanf("%d",&h)

printf("您已预定成功★房间号码为202.\n")break

case 2:printf("请输入预定天数\n")

scanf("%d",&x)

printf("请预交款为%d元\n",x*200)

printf("1.确定 2.返回")

scanf("%d",&h)

printf("您已预定成功★房间号码为305.\n")break

case 3:printf("请输入预定天数\n")

scanf("%d",&x)

printf("请预交款为%d元\n",x*300)

printf("1.确定 2.返回")

scanf("%d",&h)

printf("您已预定成功★房间号码为208.\n")break

case 4:printf("请输入预定天数\n")

scanf("%d",&x)

printf("请预交款为%d元\n",x*600)

printf("1.确定 2.返回")

scanf("%d",&h)

printf("您已预定成功★房间号码为306.\n")break

default :printf("您的输入有错请您重试")

}

}break

case 2:

{printf("请您输入您的身份z号码\n")

scanf("%d",&d[15])

printf("您已登陆成功^-^\n")

printf("请您选择退订服务种类:\n")

printf("1.单人间/夜150元\n2.双人间/夜200元\n3.标准间/夜300元\n4.总统套房/夜600元\n")

scanf("%d",&c)

switch(c)

{case 1:printf("请您输入要退定的房间号码\n")

scanf("%d",&g[3])

printf("请您输入要退订的天数\n")

scanf("%d",&y)

printf("我们将退您%d元\n",y*150)

printf("您退定成功: 谢谢您的光临 !\n")break

case 2:printf("请您输入要退定的房间号码\n")

scanf("%d",&g[3])

printf("请您输入要退订的天数\n")

scanf("%d",&y)

printf("我们将退您%d元\n",y*200)

printf("您退定成功.谢谢您的光临 !")break

case 3:printf("请您输入要退定的房间号码\n")

scanf("%d",&g[3])

printf("请您输入要退订的天数\n")

scanf("%d",&y)

printf("我们将退您%d元\n",y*300)

printf("您退定成功:谢谢您的光临 !\n")break

case 4:printf("请您输入要退定的房间号码\n")

scanf("%d",&g[3])

printf("请您输入要退订的天数\n")

scanf("%d",&y)

printf("我们将退您%d元\n",y*600)

printf("您退定成功:谢谢您的光临 !\n")break

default:printf("您的输入有错请您重试")}

}break}

{

int n

printf("谢谢光顾\n是否要再预定? 1.是2.否")

scanf("%d",&n)

if(n==1)

search()

else

printf("再见")

}

}

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

//***********************************************************************************

void initial_room()//初始化80个房间信息

void welcome() //验证用户登陆,登陆成功显示欢迎信息

void enter()

void book_room()

void check_in()

void check_out()

void inquire()

int i=0

//***********************************************************************************

struct Room

{

int number

int dank

int price

int state

}

struct Customer

{

char name[10],ID[19]

int room_number

int prepaid

int change

int day

}

void set_name(struct Customer *cs, char *n)

{

strcpy(cs->name,n)

}

void set_ID(struct Customer *cs, char *p)

{

strcpy(cs->ID,p)

}

void set_room_number(struct Customer *cs, int n)

{

cs->room_number=n

}

void set_day(struct Customer *cs, int d)

{

cs->day=d

}

void set_prepaid(struct Customer *cs, int p)

{

cs->prepaid=p

}

char *get_name(struct Customer *cs)

{

return cs->name

}

char *get_ID(struct Customer *cs)

{

return cs->ID

}

int get_room_number(struct Customer *cs)

{

return cs->room_number

}

int get_day(struct Customer *cs)

{

return cs->day

}

int get_prepaid(struct Customer *cs)

{

return cs->prepaid

}

//***********************************************************************************

struct Room room[80]

struct Customer *customer[80]

void CCustomer(struct Customer *cs)

{

printf("请您输入顾客的蚂贺姓名\n")

scanf("%s",&cs->name)

printf("请您输入顾客的身份z号码\n")

scanf("%s",&cs->ID)

cs->prepaid = cs->change = cs->day = 0

}

void FCustomer()

{

printf("该顾客退房成闷早派功!")

}

int main(void) //程序入口从这睁型里开始运行

{

char choice='1'

initial_room()//初始化80个房间的信息,分四个等级

welcome() //验证用户登陆,登陆成功显示欢迎信息

while(choice=='1')

{

enter() //根据用户的选择执行不同的功能

printf("\n")

printf("继续使用本系统请按\"1\",退出请按\"2\"! ")

fflush(stdin)

scanf("%c",&choice)

printf("\n")

}

return 0

}

//系统登陆界面***********************************************************************

void welcome() //验证用户登陆,登陆成功显示欢迎信息

{

char name[4],code[7]

printf("请输入用户名和密码(以空格隔开):\n")

scanf("%s%s",&name,&code)

while((strcmp(name,"000")!=0)||(strcmp(code,"666666")!=0))

{

printf("用户名或密码输入有误,请重新输入!\n")

scanf("%s%s",&name,&code)

}

printf("\n")

printf("\n")

printf(" ▲***************************▲\n")

printf(" △ 欢迎使用宾馆客房管理系统! △\n")

printf(" ▲***************************▲\n")

printf("\n")

}

//系统入口***************************************************************************

void enter()

{

int kind_of_service

printf("请选择服务类别:订房、入住、退房还是查询? \n")

printf(" 1->定房 2->入住 3->退房 4->查询: ")

scanf("%d",&kind_of_service)

if((kind_of_service>4) || (kind_of_service<1))

{

printf("您的输入有误,请重试!\n")

scanf("%d",&kind_of_service)

}

else

{

switch(kind_of_service)

{

case 1: book_room()

break

case 2: check_in()

break

case 3: check_out()

break

case 4: inquire()

break

}

}

}

//订房实现***************************************************************************

void book_room()

{

int room_standard,day

customer[i] = (struct Customer*)malloc(sizeof(struct Customer))

CCustomer(customer[i])

printf("请您选择预定房间的标准:\n")

printf("1.单人间/天150元\n2.双人间/天200元\n3.标准间/天300元\n4.总统套房/天600元\n")

scanf("%d",&room_standard)

printf("请输入预定天数\n")

scanf("%d",&day)

set_day(customer[i],day)

switch(room_standard)

{

int n

case 1:

printf("住房费用总共为: %d 元\n",day*150) //计算住房费用

for(n=0n<20n++) //从第一个级别的房间中查找一个空闲的房间

{

if(room[n].state==0)//state=0表示该住房没有被预定的

{

printf("预定成功★房间号码为: %d\n",room[n].number)

room[n].state=1

set_room_number(customer[i],room[n].number)

break

}

}

break

case 2:

printf("住房费用总共为: %d 元\n",day*200)

for(n=20n<40n++)

{

if(room[n].state==0)

{

printf("预定成功★房间号码为: %d\n",room[n].number)

room[n].state=1

set_room_number(customer[i],room[n].number)

break

}

}

break

case 3:

printf("住房费用总共为: %d 元\n",day*300)

for(n=40n<60n++)

{

if(room[n].state==0)

{

printf("预定成功★房间号码为: %d\n",room[n].number)

room[n].state=1

set_room_number(customer[i],room[n].number)

break

}

}

break

case 4:

printf("住房费用总共为: %d 元\n",day*600)

for(n=60n<80n++)

{

if(room[n].state==0)

{

printf("预定成功★房间号码为: %d\n",room[n].number)

room[n].state=1

set_room_number(customer[i],room[n].number)

break

}

}

break

}

i++ //住房的顾客数加1

}

//入住登记***************************************************************************

void check_in()

{

char name1[10],id1[19]

int ding_or_no,prepaid

int j

printf("该顾客订房了吗? (1->订了 2->没订) ")

scanf("%d",&ding_or_no)

if(ding_or_no==1)

{

printf("请输入顾客的姓名:\n")

scanf("%s",&name1)

printf("请输入顾客的身份z号码:\n")

scanf("%s",&id1)

for(j=0j<ij++)

{

if((strcmp(get_name(customer[j]),name1)==0)&&(strcmp(get_ID(customer[j]),id1)==0)) //查找该顾客的定房信息

{

int num=get_room_number(customer[j]) //取得定房的房间号

printf("顾客 %s 今天入住本宾馆! 房间号码为: %d\n",name1,num)

switch(num/100)

{

case 6:

prepaid=get_day(customer[j])*150

set_prepaid(customer[j],prepaid)

printf("请收房费 %d元整!\n",prepaid)//开始收费

room[num%100-1].state=2 //修改房间状态为入住状态

break

case 7:

prepaid=get_day(customer[j])*200

set_prepaid(customer[j],prepaid)

printf("请收房费 %d元整!\n",prepaid)

room[19+num%100].state=2

break

case 8:

prepaid=get_day(customer[j])*300

set_prepaid(customer[j],prepaid)

printf("请收房费 %d元整!\n",prepaid)

room[39+num%100].state=2

break

case 9:

prepaid=get_day(customer[j])*600

set_prepaid(customer[j],prepaid)

printf("请收房费 %d元整!\n",prepaid)

room[59+num%100].state=2

break

}

break

}

}

}

else

{

int room_standard,day

customer[i] = (struct Customer*)malloc(sizeof(struct Customer))

CCustomer(customer[i])

printf("请您选择预定房间的标准:\n")

printf("1.单人间/天150元\n2.双人间/天200元\n3.标准间/天300元\n4.总统套房/天600元\n")

scanf("%d",&room_standard)

printf("请输入住宿天数\n")

scanf("%d",&day)

set_day(customer[i],day)

switch(room_standard)

{

int n

case 1:

prepaid=day*150

set_prepaid(customer[i],prepaid)

printf("请收房费 %d元整!\n",prepaid)

for(n=0n<20n++)

{

if(room[n].state==0)

{

printf("入住房间号码为: %d\n",room[n].number)

room[n].state=2

set_room_number(customer[i],room[n].number)

break

}

}

break

case 2:

prepaid=day*200

set_prepaid(customer[i],prepaid)

printf("请收房费 %d元整!\n",prepaid)

for(n=20n<40n++)

{

if(room[n].state==0)

{

printf("入住房间号码为: %d\n",room[n].number)

room[n].state=2

set_room_number(customer[i],room[n].number)

break

}

}

break

case 3:

prepaid=day*300

set_prepaid(customer[i],prepaid)

printf("请收房费 %d元整!\n",prepaid)

for(n=40n<60n++)

{

if(room[n].state==0)

{

printf("入住房间号码为: %d\n",room[n].number)

room[n].state=2

set_room_number(customer[i],room[n].number)

break

}

}

break

case 4:

prepaid=day*600

set_prepaid(customer[i],prepaid)

printf("请收房费 %d元整!\n",prepaid)

for(n=60n<80n++)

{

if(room[n].state==0)

{

printf("入住房间号码为: %d\n",room[n].number)

room[n].state=2

set_room_number(customer[i],room[n].number)

break

}

}

break

}

i++

}

}

//退房结算***************************************************************************

void check_out()

{

char name2[10],id2[19]

int standard,j,room_number,day1,day2,day

printf("请输入要退房的顾客姓名和身份z号码:\n")

scanf("%s%s",&name2,&id2)

printf("请输入该顾客实住天数:\n")

scanf("%d",&day2)

for(j=0j<ij++)

{

if((strcmp(get_name(customer[j]),name2)==0)&&(strcmp(get_ID(customer[j]),id2)==0))

{

char account

room_number=get_room_number(customer[j])

standard=room_number/100

day1=get_day(customer[j])

day=day1-day2

switch(standard)

{

case 6:

printf("顾客的房间号是%d :为单人间,每天150元\n",room_number)

printf("该顾客预付了房费 %d元, 实际消费 %d元整!\n",get_prepaid(customer[j]),day2*150)

printf("\n")

if(day>0)

printf("请退给该顾客 %d 元整!\n",day*150)

if(day<0)

printf("请补收该顾客住房费 %d 元整!\n",-day*150)

break

case 7:

printf("顾客的房间号是%d :为单人间,每天200元\n",room_number)

printf("该顾客预付了房费 %d元, 实际消费 %d元整!\n",get_prepaid(customer[j]),day2*200)

printf("\n")

if(day>0)

printf("请退给该顾客 %d 元整!\n",day*200)

if(day<0)

printf("请补收该顾客住房费 %d 元整!\n",-day*200)

break

case 8:

printf("顾客的房间号是%d :为单人间,每天300元\n",room_number)

printf("该顾客预付了房费 %d元, 实际消费 %d元整!\n",get_prepaid(customer[j]),day2*300)

printf("\n")

if(day>0)

printf("请退给该顾客 %d 元整!\n",day*300)

if(day<0)

printf("请补收该顾客住房费 %d 元整!\n",-day*300)

break

case 9:

printf("顾客的房间号是%d :为单人间,每天600元\n",room_number)

printf("该顾客预付了房费 %d元, 实际消费 %d元整!\n",get_prepaid(customer[j]),day2*600)

printf("\n")

if(day>0)

printf("请退给该顾客 %d 元整!\n",day*600)

if(day<0)

printf("请补收该顾客住房费 %d 元整!\n",-day*600)

break

}

printf("\n")

printf("退房核算清楚,请按1: ")

fflush(stdin)

scanf("%c",&account)

if(account=='1')

{

int k

for(k=0k<80k++)

{

if(room[k].number==get_room_number(customer[j]))

room[k].state=0

}

i--

for(j<ij++)

{

customer[j]=customer[j+1]

}

free(customer[i])

FCustomer()

}

}

}

}

//信息查询***************************************************************************

void inquire()

{

char inquire_choice

printf("房间信息查询请按1, 顾客信息查询请按2: ")

fflush(stdin)

scanf("%c",&inquire_choice)

if(inquire_choice=='1')

{

int j,k=0

printf("\n")

printf("下列房间还没人预订,也没人入住:\n")

for(j=0j<80j++)

{

if(room[j].state==0)

{

if(k%10==0)

printf("\n")

printf("%d\t",room[j].number)

k++

}

}

printf("\n")

printf("\n")

k=0

printf("下列房间已预订:\n")

for(j=0j<80j++)

{

if(room[j].state==1)

{

if(k%10==0)

printf("\n")

printf("%d\t",room[j].number)

k++

}

}

k=0

printf("\n")

printf("\n")

printf("下列房间有人入住:\n")

for(j=0j<80j++)

{

if(room[j].state==2)

{

if(k%10==0)

printf("\n")

printf("%d\t",room[j].number)

k++

}

}

printf("\n")

printf("\n")

}

else if(inquire_choice=='2')

{

char inquire_choice

int j

printf("按姓名查询请按1, 按身份z查询请按2: \n")

fflush(stdin)

scanf("%c",&inquire_choice)

if(inquire_choice=='1')

{

char name3[10]

printf("请输入顾客的姓名: \n")

scanf("%s",&name3)

for(j=0j<ij++)

{

if(strcmp(get_name(customer[j]),name3)==0)

{

printf("%s的住房信息如下:\n",name3)

printf("\t房间号为: %d\n",get_room_number(customer[j]))

printf("\t预付房费为: %d\n",get_prepaid(customer[j]))

}

}

}

if(inquire_choice=='2')

{

char id3[10]

int j

printf("请输入顾客的身份z: \n")

scanf("%s",&id3)

for(j=0j<ij++)

{

if(strcmp(get_ID(customer[j]),id3)==0)

{

printf("%s的住房信息如下:\n",get_name(customer[j]))

printf("\t房间号为: %d\n",get_room_number(customer[j]))

printf("\t预付房费为: %d\n",get_prepaid(customer[j]))

}

}

}

}

}

//房间信息初始化*********************************************************************

void initial_room() //对80个房间进行初始化,分4个等级

{

int j,k=601

for(j=0j<20j++)

{

room[j].number=k++

room[j].dank=1

room[j].price=150

room[j].state=0

}

k=701

for(j=20j<40j++)

{

room[j].number=k++

room[j].dank=2

room[j].price=200

room[j].state=0

}

k=801

for(j=40j<60j++)

{

room[j].number=k++

room[j].dank=3

room[j].price=300

room[j].state=0

}

k=901

for(j=60j<80j++)

{

room[j].number=k++

room[j].dank=4

room[j].price=600

room[j].state=0

}

}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12337188.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-24
下一篇 2023-05-24

发表评论

登录后才能评论

评论列表(0条)

保存