客房管理系统C语言.docx

上传人:b****5 文档编号:4451614 上传时间:2022-12-01 格式:DOCX 页数:22 大小:22.58KB
下载 相关 举报
客房管理系统C语言.docx_第1页
第1页 / 共22页
客房管理系统C语言.docx_第2页
第2页 / 共22页
客房管理系统C语言.docx_第3页
第3页 / 共22页
客房管理系统C语言.docx_第4页
第4页 / 共22页
客房管理系统C语言.docx_第5页
第5页 / 共22页
点击查看更多>>
下载资源
资源描述

客房管理系统C语言.docx

《客房管理系统C语言.docx》由会员分享,可在线阅读,更多相关《客房管理系统C语言.docx(22页珍藏版)》请在冰豆网上搜索。

客房管理系统C语言.docx

客房管理系统C语言

三峡大学理学院2010级电子信息科学与技术专业

《高级语言程序设计》课程设计

说明书

设计题目:

客房管理系统

班级:

20101421

学号:

2010142139

姓名:

徐晶

2011-11-23

:

完成日期

设计任务……………………(2一、)

二、2)需求分析……………………(三、(系统模块图…………………2)

)四、(模块说明……………………3用户说明…………………(五、18))18六、(测试结果…………………

设计小结…………………七、19()

)19(参考目录…………………八、.

设计任务客房管理系统:

一、实现用户登记功能,要提供结构体的输入操作,实现统计功能,要提供相应的统计操作,实现查询功能,要提供查找操作,实现修改功能,要提供修改操作;另外还有提供键盘式菜单实现功能选择。

需求分析二、:

1.总体分析:

整个客房管理系统被设计为用户登记模块,统计模块,查询模块,和修改模块。

2.详细分析:

(1)用户登记模块提示用户输入自身信息以及客房信息,把数据存入Room数组中。

(2)统计模块18设置计数器,顺序遍历ROOM数组来实现,实现对房客数、某一天的房客数的统计。

(3)查询模块通过基本查找算法查找Room数组,可以按房间号、价格、房间标记、用户姓名、居民身份证查询。

(4)修改模块采用基本查找算法在数组找到要修改的数据。

三、系统模块图

根据需求分析,可以对这个系统的设计分为以下几个模块:

客户信息管理系

数据输入数据统计数据查询数据修改数据删除

四、模块说明:

一个较大的C语言程序不外乎由多个函数组成,本程序也并不例外。

现就本程序中涉及的各个函数的代码和功能分别进行说明。

1、主函数部分:

程序:

voidmain()/**主函数**/

{

intn,w;

menu();

do

{

printf(\\tPleasechoiceyounumber(1-5));

scanf(%d,&n);

if(n<1||n>5)

w=1,getchar();

elsew=0;

}while(w==1);

switch(n)

{

case1:

regist();break;

case2:

stati();break;

case3:

search();break;

case4:

modify();break;

case5:

exit(0);

}

}

voidmenu()/**菜单函数**/

************\n);

客房管理系统{printf(\\t\t************

puts(\

\t\t\t

(1).登记\n);

puts(\\t\t

(2).统计\n);

puts(\\t\t(3).查询\n);

puts(\\t\t(4).修改\n);

puts(\\t\t(5).退出\n);

puts(\

\t***********************************************************\n);

}

voidreturn_confirm(void)

{

printf(\

按任意键返回……\n);

getchar();

}

#includestdio.h

#includestring.h//在使用中要用到的字符串都包含在本文件中

#includestdlib.h

#includemath.h

#defineNUM50

structClient

{

charName[20];

intSex;//famale0,male1;

intAge;

charID_card[20];/*居民身份证*/

intyear;

intmonth;

intdate;/*住店时间*/

};

structHotel

{

charRoom_ID[10];/*房间号*/

charTel[10];

intPrice;/*住房单价*/

intSign;

structClientClient_list;/*实现两个结构体的嵌套*/

}Room[NUM];

注:

menu函数能提供菜单方式选择功能,可以根据用户需要进入到所想要的操作模块中,此外把menu函数独立出来,可以方便随时对它进行调用,容易返回到系统界面。

并用结构体来存放客户信息。

2、各功能模块函数部分:

(1)输入模块:

对信息进行输入][需求分析程序:

voidregist()/**登记函数**/

{

voidprintf_one(inti);

voidsave(intn);

voidprintf_back();

intload();

voidprintf_face();

inti,n,c;

n=load();

do

{

for(i=0;i

{

if(Room[i].Sign==1)

{

printf(Room[%s]hasbeenfull\n,Room[i].Room_ID);

}

else

{

puts(\

registernewrecord\n);

printf(\

Room[%s]isempty,Room[i].Room_ID);

printf(\

pleaseenterRoom[%s]'sinformation,Room[i].Room_ID);

puts(\

pleaseentercustomer'sName\n);

scanf(s,&Room[i].Client_list.Name);

printf(\

pleaseenterSexandAge\n);

scanf(==,&Room[i].Client_list.Sex,&Room[i].Client_list.Age);

puts(\

pleaseentercustomer'sID_card\n);

scanf(s,&Room[i].Client_list.ID_card);

printf(\

pleaseenteryearandmonthanddate\n);

scanf(]]],&Room

[i].Client_list.year,&Room[i].Client_list.month,&Room[i].Client_list.date);

Room[i].Sign=1;//把房间标记为已满

printf_face();

printf_one(i);

printf(\

\nAreyousure?

\n\n\t1.sure\t2.cancleandagain\t3.Backwithoutsave

[]\b\b);

scanf(%d,&c);

if(c==1)

{save(n);

printf_back();

}

elseif(c!

=2)menu();

}

}

}while(c==2);

return_confirm();

}

intload()

{

FILE*fp;

inti;

if((fp=fopen(Hotel.txt,

))==NULL)

{

printf(\

Cannotopenfile\n);

exit(0);

}

for(i=0;!

feof(fp);i++)

fscanf(fp,\

%s%s%d%d%s%d%d%s%d%d%d\n,&Room

[i].Room_ID,&Room[i].Tel,&Room[i].Price,

&Room[i].Sign,&Room[i].Client_list.Name,&Room[i].Client_list.Sex,

&Room[i].Client_list.Age,&Room[i].Client_list.ID_card,

&Room[i].Client_list.year,&Room

[i].Client_list.month,&Room[i].Client_list.date);

fclose(fp);

return(i);

}

voidprintf_one(inti)

{

printf(\

%-5s%5s]%d,Room[i].Room_ID,Room[i].Tel,Room

[i].Price,Room[i].Sign);

printf(\

%-s]]_x0010_s,Room[i].Client_list.Name,Room

[i].Client_list.Sex,Room[i].Client_list.Age,Room[i].Client_list.ID_card);

printf(\

%-5d]]\n,Room[i].Client_list.year,Room

[i].Client_list.month,Room[i].Client_list.date);

}

voidsave(intn)

{

FILE*fp;

inti;

if((fp=fopen(Hotel.txt,w))==NULL)

{

printf(\

Cannotopenfile\n);

exit(0);

}

for(i=0;i

fprintf(fp,%-5s%-15s%-5d%-5d%-15s%-5d%-5d%-20s%-5d%-5d%-5d\n,

Room[i].Room_ID,Room[i].Tel,Room[i].Price,Room[i].Sign,

Room[i].Client_list.Name,Room[i].Client_list.Sex,

Room[i].Client_list.Age,Room[i].Client_list.ID_card,Room[i].Client_list.year,

Room[i].Client_list.month,Room[i].Client_list.date);

fclose(fp);

}

voidprintf_face()

{

printf(\

Room_IDTelPriceSign);

printf(\

NameSexAgeID_card);

printf(\

yearmonthdate);

}

voidprintf_back()

{

intw;

printf(\

\n\tSuccessful.^-^\n\n);

printf(Doyouwanttoback?

\n\n\t1).Yes\t2).No:

[]\b\b);

scanf(%d,&w);

if(w==1)

menu();

}

本函数的功能为登记用户及房间信息,包括姓名、性别、年龄、年份、月份、日期及身份证、。

系统依次分配房间号并定义此房间为非空。

管理员可根据具体情况登记相应用户人数的信息。

在此申明由于本程序并未将用户信息存入磁盘,因此务必先登记用户信息再执行功能菜单中的其他功能。

(2)统计模块:

该模块的功能是显示所有客户记录信息。

需求分析][程序:

voidstati()/***统计函数***/

{

voidTime_stati();

voidRoom_ID_stati();

voidPrice_stati();

intc;

do

{

puts(\

\nstatisticby=>\n\n1).Time2).Room_ID3)Price);

printf(Whichyouneed<1-3>?

:

[]\b\b);

scanf(%d,&c);

if(c>3||c<1)

{

puts(\

Choiceerrror!

Pleaseagain!

);

getchar();

}

}while(c>3||c<1);

switch(c)

{

case1:

Time_stati();break;

case2:

Room_ID_stati();break;

case3:

Price_stati();break;

}

return_confirm();

}

voidTime_stati()/******统计入住的时间*****/

{

intn,i,k=0,w,w0=1,w2=0;

structHotels;

n=load();

do

{

do

{

w=-1;

puts(\

pleaseenterthetimethatyouwanttostatistic.\n);

puts(\

pleaseentertheyear:

);

scanf(%d,&s.Client_list.year);

puts(\

pleaseenterthemonth:

);

scanf(%d,&s.Client_list.month);

puts(\

pleaseenterthedate:

);

scanf(%d,&s.Client_list.date);

for(i=0,k=0;i

if(s.Client_list.year==Room[i].Client_list.year&&s.Client_list.month==Room

[i].Client_list.month&&s.Client_list.date==Room[i].Client_list.date)

{

w=i;

printf_face();

printf_one(i);

k++;

}

printf(\

Thereare%drecordersthisday!

k);

if(w==-1)

{

printf(\

NOexist!

please.Entererror!

!

);

printf(\

Therearenorecordersthisday!

);

printf(\

Doyouwanttoretryanother?

\n\n\t1).Yes2).Noandback3).Backto

menu[]\b\b);

scanf(%d,&w0);

if(w0==2)stati();

elseif(w0!

=1)menu();

}

else

{printf(\

Successful!

^_^^_^.\nEnteranothertime?

\n\n\t1).Yes2).Backto

menu\t[]\b\b);

scanf(%d,&w2);

if(w2!

=1)menu();

}

}while(w==-1&&w0==1);

}while(w2==1);

}

voidRoom_ID_stati()/*******统计房间号******/

{

intn,i,k=0,w,w0=1,w2=0;

structHotels;

n=load();

do

{

do

{

w=-1;

puts(\

pleaseentertheRoom_IDthatyouwanttostatistic.\n);

scanf(%s,&s.Room_ID);

for(i=0,k=0;i

if(strcmp(s.Room_ID,Room[i].Room_ID)==0)

{

w=i;

printf_face();

printf_one(i);

k++;

}

printf(\

Thereare%drecordersinthisRoom!

k);

if(w==-1)

{

printf(\

NOexist!

please.Entererror!

!

);

printf(\

TherearenorecordersinthisRoom!

);

printf(\

Doyouwanttoretryanother?

\n\n\t1).Yes2).Noandback3).Backto

menu[]\b\b);

scanf(%d,&w0);

if(w0==2)stati();

elseif(w0!

=1)menu();

}

else

{printf(\

Successful!

^_^^_^.\nEnteranotherRoom_ID?

\n\n\t1).Yes2).Backto

menu\t[]\b\b);

scanf(%d,&w2);

if(w2!

=1)menu();

}

}while(w==-1&&w0==1);

}while(w2==1);

}

voidPrice_stati()/*******统计房间单价******/

{

intn,i,k=0,w,w0=1,w2=0;

structHotels;

n=load();

do

{

do

{

w=-1;

puts(\

pleaseentertheRoom'spricethatyouwanttostatistic.\n);

scanf(%d,&s.Price);

for(i=0,k=0;i

if(s.Price==Room[i].Price)

{

w=i;

printf_face();

printf_one(i);

k++;

}

printf(\

Thereare%drecordersatthisprice!

k);

if(w==-1)

{

printf(\

NOexist!

please.Entererror!

!

);

printf(\

Therearenorecordersatthisprice!

);

printf(\

Doyouwanttoretryanother?

\n\n\t1).Yes2).Noandback3).Backto

menu[]\b\b);

scanf(%d,&w0);

if(w0==2)stati();

elseif(w0!

=1)menu();

}

else

{printf(\

Successful!

.\nEnteranotherRoom'price?

\n\n\t1).Yes2).Backto

menu\t[]\b\b);

scanf(%d,&w2);

if(w2!

=1)menu();

}

}while(w==-1&&w0==1);

}while(w2==1);

}

本函数的功能为输出统计功能菜单选项,包括根据按性别统计、根据年龄统计及根据入住时间统计。

系统根据输入的选项执行相应的函数。

(3)查找模块

程序:

voidsearch()/********查找函数********/

{

inti,n,k,w1=1,w2,w3;

structHotels;

n=load();

do

{

w2=-1;

do

{

k=-1;

printf(\

\nEnterID_cardthatyouwanttosearch!

ID_card:

);

scanf(%s,&s.Client_list.ID_card);

for(i=0;i

if(strcmp(s.Client_list.ID_card,Room

[i].Client_list.ID_card)==0)

{

k=i;

w2=1;

printf_one(k);

break;

}

if(k==-1)

{

printf(\

\nNoexit!

Please.);

printf(\

\nAreyouagain?

\n\t1).again2).Noandback[]\b\b);

scanf(%d,&w1);

menu();if(w1!

=1)

}

}while(k==-1&&w1==1);

if(w2==1)

{

printf(\

\nSuccessful.^_^.\n);

printf(\

Whatdoyouwanttodo?

\n\t1).Searchanother2).Backtomenu[]\b\b);

scanf(%d,&w3);

menu();if(w3!

=1)

}

}while(w3==1);

}

包括根据房间号查询、本函数的功能为输出查询功能菜单选项,根据姓名查询及根据性别查询。

系统根据输入的选项执行相应的函数。

)修改模块(4该模块的功能是插入客户记录信息并且不能覆盖原有客户信息。

需求分析[]

程序:

voidmodify()/********修改函数********/

{

intmodify_date(inti,intk);

structHotels;

inti,n,k,w0=1,w1,w2=0;

n=load();

do

{

k=-1;

printf_face();

for(i=0;i

{

if((i!

=0)&&(i%4)==0)

{

printf(\

\nRememberRoom_IDthatyouneedtomodify!

Passanykeyto

conti

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高中教育 > 高中教育

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1