客房标准管理系统C语言_第1页
客房标准管理系统C语言_第2页
客房标准管理系统C语言_第3页
客房标准管理系统C语言_第4页
客房标准管理系统C语言_第5页
已阅读5页,还剩22页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

三峡大学理学院级电子信息科学

与技术专业

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

阐明书

设计题目:客房管理系统

班级:

学号:

姓名:

完毕日期

目录

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

二、需求分析................(2)

三、系统模块图..............(2)

四、模块阐明................(3)

五、顾客阐明...............(18)

六、测试成果...............(18)

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

八、参照目录...............(19)

一、设计任务:客房管理系统

实现顾客登记功能,要提供构造体输入操作,实现记录功能,要

提供相应记录操作,实现查询功能,要提供查找操作,实现修改功能,

要提供修改操作;比外尚有提供键盘式菜单实现功能选取。

二、需求分析:

1.总体分析:整个客房管理系统被设计为顾客登记模块,记录模块,

查询模块,和修改模块。

2.详细分析:

(1)顾客登记模块提示顾客输入自身信息以及客房信息,把数据存

入Room数组中。

(2)记录模块18没立计数器,顺序遍历ROOM数组来实现,实现

对房客数、某一天房客数记录。

(3)查询模块通过基本查找算法查找Room数组,可以按房间号、

价格、房间标记、顾客姓名、居民身份证查询。

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

三、系统模块图

依照需求分析,可以对这个系统设计分为如下几种模块:

客户信息管理系统

数据输入数据记录数据查询数据修改数据删除

四、模块阐明:

一种较大c语言程序不外乎由各种函数构成,本程序也并不例

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

puts("\t\t\t(2).记录\n");

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

putsC'\t\i\t(4).修改\n");

(5).退出\n°);

voidre(urn_confirm(void)

(

printf("\n按任意键返回……\n");

getchar();

)

#include"stdio.h"

#include"string.h"〃在使用中要用到字符串都包括在本文献

include"stdlib.h"

#include"math.h"

#defineNUM50

structClient

charName[20];

intSex;//famalc0,malc1;

intAge;

charID_card[201;/*居民身份证*/

intyear;

intmonth;

intdate;/*住店时间*/

};

structHotel

(

charRoom_ID[10];/*房间号

charTel110J;

intPrice;/*住房单价*/

intSign;

structClientClientjisl;/*实现两个构造体嵌套*/

}Room[NUM];

注:menu函数能提供菜单方式选取功能,可以依照顾客需要进入到所想

要操作模块中,此外把menu函数独立出来,可以以便随时对它进行调用,容

易返回到系统界面。并用构造体来存储客户信息。

2、各功能模块函数某些:

(1)输入模块:[需求分析]对信息进行输入

程序:

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

{

voidprintLonc(inti);

voidsave(inln);

voidprint匚back。;

intIoad();

voidprinl匚face。;

inti,n,c:

n=load();

do

for(i=0;i<n;i++)

{

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

{

printf("Room[%s]hasbeenfull'n",Roon】[i].Room」D):

)

else

{

puts("\nrcgistcrnewiccord\n");

printf("\nRooml%s]isempty".Room[i].Room_lD);

printf("\npleaseenterRoom[%s],sinformation",Room[i].Room_ID);

puts("\npleaseentercustomer'sName\n");

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

printf("\npleaseenterSexandAge\n");

scanf("%3d%3d",&Room[i].CIient_lisl.Sex,&Room[i].Client_list.Age);

puts("\npleaseentercustomer'sID_card\n");

scanf("%20s",&Room[i].Clicnt_list.ID_card):

printf("\npleaseenteryearandmonthandda(e\n");

scanf("%5d%5d%5d",&Room

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

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

print匚face。;

printf_one(i);

printf("\n\nAreyousure?\n\n\tI.sure\t2.cancleandagain\t3.Backwithoutsave

[]\b\b");

scanfC'%d",&c);

if(c==l)

{save(n);

printf_back();

)

elseif(c!=2)menu();

}

}

}vvhile(c==2);

return_confirm();

)

intload()

FILE*fp;

inti:

if((fp=fopen("Hoiel.txl","r"))==NULL)

{

printf("\nCannotopenfile\n");

exit(O);

)

for(i=0;!feof(fp);i++)

fscanf(fp,"\n%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,&RoomliJ.Client_list.Name,&Room[iJ.Client_list.Sex»

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

&Room[i].CIient」ist.ycar,&Room

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

fclose(fp):

return(i);

voidprintfLonc(inti)

{

printf("\n%-5s%5s%5d%d",Room[i].Room_ID,Room[i].TeLRoom

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

printf("\n%-s%5d%5d%10s',,Room[i].CIientJist.Name,Room

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

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

[i).Clienl_list.month,Roorn[i].CIient_list.date);

voidsave(intn)

{

FILE*fp;

inti;

if((fp=fopen("Hotel.txr,"w"))==NULL)

printf("\nCannotopenfile\n");

exit(O):

)

for(i=0;i<n;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[iJ.CIientJist.Name,Rooin[iJ.Client_list.Sex,

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

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

fclose(fp);

}

voidprinlfLface()

{

printf("\nRoom_IDTelPriceSign");

printf("\nNameSexAgeID_card");

printf("\nyearmonthdate");

I

voidprintLbackO

|

intw:

printf("\n\n\tSuccessfuLA-A\n\n");

printf("Doyouwanttoback?\n\n\tl).Yes\t2).No:[]\b\b');

scanf("%d”,&w);

if(w==l)

menu():

本函数功能为登记顾客及房间信息,涉及姓名、性别、年龄、年

份、月份、日期及身份证、。系统依次分派房间号并定义此房间为非

空。管理员可依照详细状况登记相应顾客人数信息。在此声明由于本

程序并未将顾客信息存入磁盘,因而务必先登记顾客信息再执行功能

菜单中其她功能。

(2)记录模块:[需求分析]该模块功能是显示所有客户记录信息。

程序:

voidstati()/***记录函数***/

(

voidTime_stati();

voidRoom_ID_stati();

voidPrice_stati();

intc:

do

(

puts("\n\nstatisticby=>\n\nI).Titne2).Room_ID3)Price"):

printf("Whichyouneed<l-3>?:[]\b\bM);

scanf("%d”,&c);

if(c>3||c<l)

{

puts("\nChoiceerrror!Pleaseagain!"):

getchar();

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

switch(c)

case1:Timc_stati();brcak;

case2:Room_ID_stati();break:

case3:Price_stati();break;

)

retum_confirni();

}

voidTimc_stati()/******记录入住时间*****/

(

intn,i,k=0,w,w0=l,w2=();

structHotels;

n=load():

do

(

do

(

w=-l;

puls("\npleaseenterthelime(hatyouwanttostatistic.\n");

puts("\npleaseentertheyear:");

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

puts("\npleaseenterthemonth:");

scanf("%d",&s.Clicnt_list.month);

puls("\npleaseenterthedate:");

scanf("%d",&s.ClientJist.date);

for(i=0,k=0;i<n;i++)

if(s.Client」ist.year==Room[i].Client_list.year&&s.Client_list.nionth==Room

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

{

w=i;

printf_face();

printf_one(i);

k++;

)

printf("\nThereare%drecordersthisday!",k);

if(w==,l)

{

printf("\nNOexist!please.Entererror!!");

printfC'XnTherearenorecordersthisday!");

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

menul]\b\b");

scanf("%d”,&wO);

if(w0==2)stati();

elseif(wO!=l)menu();

)

else

{printf("\nSuccessful!A_AA_A.\nEnteranothertime?\n\n\tl).Yes2).Backto

menu\tl]\b\b");

scanf("%d",&w2);

if(w2!=l)mcnu();

}while(w==-l&&wO==l);

(while(w2==l);

voidRoom_ID_stati()/*******记录房问号******/

(

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

structHotels;

n=load();

do

{

do

(

w=-l;

puts("\npleaseentertheRoom_ID(hatyouwanttostatistic."1");

scanf("%s",&s.Room_ID);

for(i=0,k=0;i<n;i++)

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

{

w=i;

printflfacc。;

print匚one(i);

k++:

)

printf("\nThereare%drecordersinthisRoom!",k);

if(w==-l)

printf("\nNOexist!please.Entererror!!");

printf("\nTherearenorecordersinthisRoom!");

printf(,'\nDoyouwanttoretryanother?\n\n\tl).Yes2).Noandback3).Backto

mcnu[]\b\bu);

scanf("%d",&wO);

if(w0==2)stati();

elseif(w()!=l)menu。;

)

else

{printf("\nSuccessful!A_AA_A.\nEnteranotherRoom_ID?\n\n\tI).Yes2).Backto

mcnu\t[]\b\b");

scanf("%d",&w2);

if(w2!=l)menu();

I

}while(w==-l&&w0==1):

}while(w2==l);

}

voidPrice_stati()/*******记录房间单价******/

(

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

structHotels;

n=load():

do

(

do

w=-l;

puts("\npleaseentertheRoom'spricethatyouwanttostatistic.\nu);

scanf("%d",&s,Price);

for(i=0,k=0;i<n;i++)

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

(

w=i;

printf_face():

prim匚one(i);

k++;

)

printf("\nThereare%drecordersatthisprice!",k);

if(w==-1)

{

printf("\nNOexist!please.Entererror!!");

printfCAnTherearenorecordersatthisprice!');

printf("\nDoyouwanttoretrj/another?\n\ii\t1).Yes2).Noandback3).Backto

menu!]\b\bu);

scanf("%d",&wO):

if(w0==2)stati();

elseif(wO!=l)menu();

}

else

{printf("\nSuccessful!AnEnteranotherRoom'price?\n\n\t1).Yes2).Backto

menu\t[]\b\b");

scanf("%d",&w2);

if(w2!=l)menu。;

)while(w==-l&&w()==I):

}while(w2==l);

)

本函数功能为输出记录功能菜单选项,涉及依照按性别记录、

依照年龄记录及依照入住时间记录。系统依照输入选项执行相应函

数。

(3)查找模块

程序:

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

(

inti,n,k,wl=l,w2,w3:

structHotels;

n=Ioad();

do

{

w2=-1;

do

(

k=-l:

printf("\n\nEnterlD_cardthatyouwanttosearch!lD_card:");

scanf("%s”,&s.Client」ist.ID_card);

for(i=0;i<n;i++)

if(slrcmp(s.Client_lisl.ID_card,Room

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

k=i;

w2=1;

printf_cnc(k);

break;

)

if(k==-l)

(

printf("'.n\nNoexit!Please."):

printf("'.n\nAreyouagain?\n\tl).again2).Noandback[]\b\b");

scanf("%d",&wl);

if(wl!=l)menu();

I

}while(k==-l&&wl==l);

if(w2==l)

(

printf("\n\nSuccessful.A_A.\n");

printf("\nWhatdoyouwanttodo?\n\tl).Searchanother2).Backtomenu[]\b\b");

scanf("%d”,&w3);

if(w3!=l)menu();

}

}while(w3==l);

本函数功能为输出查询功能菜单选项,涉及依照房间号查询、

依照姓名查询及依照性别查询。系统依照输入选项执行相应函数。

(4)修改模块

[需求分析]该模块功能是插入客户记录信息并且不能覆盖原有客户信息。

程序:

voidmodifyO/********修改函数********/

(

inimodify_date(inti,inlk);

structHotels;

inti,n,k,wO=I,wI,w2=0:

n=load();

do

{

k=-l:

printCfacc();

for(i=0;i<n;i++)

{

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

(

pnntf("'.n\nRcmcnibcrRoom_IDthatyouneedtomodify!Passanykeyto

continue

gctchar();

puts("\n\n");

)

printflonc(i);

do

printf("\n\nEnterRoom_IDthatyouwanttomodify!Room」D:"):

scanf("%s",s.Rooin_ID);

for(i=0;i<n;i++)

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

(

k=i;

s=Room[i];

)

if(k==-l)printf("\n\nNoexist!Pleaseagain");

}whilc(k==-l);

printlLfacc();

printf_one(k);

w1=modify_date(k.n);

if(wl==l)

(

printf("\n\nSuccessfulA_AA_A.\nAreyoumodifyanother?\n\ii\t1).Yes2).Backwith

save\t[]\b\b");

scanf(1,%d",&wO);

w2=l:

)

else

(

w0=0;

if(w2==l)

Room[i]=s;

}

if(wO!=l&&w2==l)

save(n);

}while(wO==l);

nienu();

)

inimodify_date(intk)

(

inic,wl;

do

(

puts("\n\nmodifyby=>\n\nl).Namc2).Sex3).Agc\n4).ID_card5).Timc6).Alldata

7).Canclcandback");

printf("Whichyouneed?:[J\b\b");

scanf("%d",&c):

if(c>7||c<l)

{

puts("\nChoiceeirror!Pleaseagain!"):

getchar();

)

)

while(c>7||c<l);

do

(

switch(c)

easel:printf("PleaseenternewName:");scanf("%s",&Rooni[i].ClientJist.Name);break;

case2:printf("PleaseenternewSex:");scanf("%d",&Room[i].Client_list.Sex);break;

case3:printf("PleaseenternewAge:");scanf("%d",&Room[i].Clientjist.Age);break;

case4:printf(',PleaseenterncvviD_card:");scanf("%s",&Rooin[i].Client_list.ID_card);bicak

9

case5:printf(,'Pleaseenternewyearmonthdate:");scanf("%d%d%d,1,&Room[i].Client_.ist.y

car,&Room[i].Clicnt_list.month,&Room[i].Clicnt_list.datc);brcak;

case6:prinlf("PleaseenternewAlldata:");

puts("\npleaseentercustomer'snewName\n"):

scanf(n%15s",&Room[iJ.Client_list.Name);

printf("\nplcascenternewSexandAgc\n');

scanf(*'%3d%3d",&Room[i].Client_list.Sex,&Room[i].Client_list.Age);

puts("\npleaseenternewcustomer'sID_card\n");

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

printf("\npleaseenternewyearandmonthanddate\nM);

scanf("%5d%5d%5d'\&Room[i].Client_list.year,&Room[i].Client_list.month>

&Room[i].Client_list.date);break;

case7:rnenu();

puts("\nNow.pleaseensuretheinformationyouentered.");

print匚face。;

printLone(i);

printf("\nAreyousure?\n\n\tl).Sure2).Noandremodify3).Backwithoutsaveinthis

time[]\b\b");

scanf("%d",&wl):

}while(wl==2);

return(wl);

本函数功能为系统依照输入姓名调出该顾客及所在房间信息、,同

步输出修改功能菜单选项,涉及修改性别、修改年龄、修改入住年份、

修改月份及修改日期C系统依照输入选项修改顾客相应信息。

五、顾客使用阐明

在运营程序后,会浮现主菜单,分别输入1、2、3、4后会链接

到相应登记、记录、查询、修改程序。例如:在登记程序中,依照系

统提示依次输入姓名、性别、年龄、日期等信息,,然后依照系统提示

决定拟定、返回修改以及返回菜单。返回菜单后按任意键返回。若要

进行别程序,则需要重新运营程序。

六、测试成果

1.菜单函数:

<1〉.登记

<2〉.统计

<3〉.查询

<4〉.修改

<5〉.退出

PleasechoiceyounuRber<l-5>

2.登记函数:

■'H:\C语言\c语言课程'声层管理系统\4\Debug\5.exe"

Pleasechoiceyoununber<l_5>l

registernewrecord

Roon[0]isempty

pleaseenterRoomtOJ'sinfornation

pleaseentercustoner,sName

xujing

pleaseenterSexandAge

1

22

pleaseentercustomer'sID_card

1234

pleaseenteryearandnnnthanddate

2011

11

23

3.记录函数:

(1)用时间记录

e・H:\C语二c语言课程、客房售统\4\Debug\5.exe"1"1I

Roon_IDTelPriceSign

NameSexAgeID_cai'd

yearmonthdate

xujing1221

561221234

20111123

Thereare1recordersthisday?

Successful?^-J

Enteranothertine?

1>.¥es2>.Backtomenu(]

(2)用房间号记录:

o回

■'H:\C语言\c语言法程、含层管理系统\4\Debug\5.exe'।

<4).修改pj

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论