版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、中國(guó)地質(zhì)大學(xué)(武漢)C 語言課程設(shè)計(jì)論文學(xué)院 :專業(yè) :題目 :客房管理系統(tǒng)設(shè)計(jì)班級(jí) :姓名 :學(xué)號(hào) :指導(dǎo)教師:2010年 9月 6日?qǐng)?bào)告目錄報(bào)告目錄1報(bào)告摘要2一、題目要求3二、需求分析3三、總體設(shè)計(jì)3四、詳細(xì)設(shè)計(jì)41、主函數(shù)部分: .42、各功能模塊函數(shù)部分:6( 1)輸入模塊6( 2)統(tǒng)計(jì)模塊7( 3)查找模塊10( 4)修改模塊123、公共函數(shù)部分: .16( 1)保存函數(shù) save()16( 2)加載函數(shù) load_room()16( 3)一個(gè)任務(wù)結(jié)束時(shí)的選擇函數(shù)printf_back()17( 4)修改整條數(shù)據(jù)記錄函數(shù)modify_data(int i,int n)17五、上機(jī)操
2、作18總結(jié)211報(bào)告摘要此次 C語言課程設(shè)計(jì)我選擇的是客房管理系統(tǒng)設(shè)計(jì),系統(tǒng)設(shè)計(jì)采用 c 語言在 microsoft visual c+6.0下編譯而成。客房管理系統(tǒng)包括客戶基本信息的錄入、統(tǒng)計(jì)、查詢、修改功能。系統(tǒng)開發(fā)由分析、設(shè)計(jì)、實(shí)施、調(diào)試和測(cè)試等階段組成,其中信息管理為開發(fā)的重點(diǎn)。在程序設(shè)計(jì)中結(jié)構(gòu)體的調(diào)用與文件的讀寫為編譯的重點(diǎn)部分。2一、題目要求客戶信息包括身份證號(hào)、姓名、性別、年齡、房間號(hào)。試設(shè)計(jì)一客房管理系統(tǒng),使之能提供以下功能:( 1) 系統(tǒng)以菜單方式工作( 2) 客戶信息錄入功能(客戶信息用文件保存)( 3) 客戶信息統(tǒng)計(jì)功能( 4) 客戶信息查詢功能,查詢方式( 5) 客戶信
3、息修改功能(可選項(xiàng))建立客戶信息結(jié)構(gòu)體,結(jié)構(gòu)體成員包括身份證號(hào)、姓名、性別、年齡、房間號(hào)提示 二、需求分析根據(jù)題目要求,要求對(duì)客戶信息進(jìn)行輸入、輸出等操作;在程序中需要瀏覽客戶的信息,應(yīng)提供顯示、統(tǒng)計(jì)、查詢、修改等操作;另外還應(yīng)提供鍵盤式選擇菜單實(shí)現(xiàn)功能選擇。三、總體設(shè)計(jì)根據(jù)需求分析,可以對(duì)這個(gè)系統(tǒng)的設(shè)計(jì)分為以下幾個(gè)模塊:客戶信息管理系統(tǒng)數(shù)據(jù)輸入數(shù)據(jù)統(tǒng)計(jì)數(shù)據(jù)查詢數(shù)據(jù)修改數(shù)據(jù)刪除系統(tǒng)功能模塊圖3四、詳細(xì)設(shè)計(jì)1、主函數(shù)部分:主函數(shù)一般設(shè)計(jì)得比較簡(jiǎn)潔,只提供輸入,處理和輸出部分的函數(shù)調(diào)用。其中各功能模塊用菜單方式選擇。并使用藍(lán)色作為背景顏色。流程圖 :顯示各功能選項(xiàng)N輸入 n ,判斷 n 是否是 0
4、-5Y根據(jù) n 的值調(diào)用各功能模塊函數(shù)主函數(shù)流程圖main()/* 主函數(shù) */ int i;puts("歡迎進(jìn)入 :");for (i=0;i<100;i+)system("color 1f"); printf("nnnnntt客房管理系統(tǒng) ");printf("nnntttPress any key to continue.");printf("nnnnnnnnnnnntttttttt-By童川 n");getch();menu(); void menu()/*菜單函數(shù) */int n
5、,w;doputs("nnnt*MENU*nn");puts("ttt|(1).Regist|n");puts("ttt|(2).Statistics|n");puts("ttt|(3).Search|n");puts("ttt|(4).Modify|n");puts("ttt|(5).Exit|n");4puts("nt*n"); printf("ttPlease choice you number(1-5)"); scanf(&qu
6、ot;%d",&n);if(n<1|n>5) w=1,getchar();else w=0;while(w=1);switch(n)case 1:regist();break;case 2:stat();break;case 3:search();break;case 4:modify();break;case 5:exit(0);注: menu 函數(shù)能提供菜單方式選擇功能,可以根據(jù)用戶需要進(jìn)入到所想要的操作模塊中,此外把 menu 函數(shù)獨(dú)立出來,可以方便隨時(shí)對(duì)它進(jìn)行調(diào)用,容易返回到系統(tǒng)界面。并用結(jié)構(gòu)體來存放客戶信息:struct clientchar name2
7、0;int sex;int age;char ID_card20; /* 居民身份證 */int year;int month;int date;/* 住店時(shí)間 */;struct hotelint room_ID;/* 房間號(hào) */char tel15;int price;/* 住房單價(jià) */int sign;struct client client_listM; /* 實(shí)現(xiàn)兩個(gè)結(jié)構(gòu)體的嵌套 */roomN;/* r,p 為全局變量 */int r=0;p=0;void menu();void search_one();5void search_day();void modify();voi
8、d modify_one();void load_room();void modify_day();void modify_s(int j,int i);void save();void search();void stat_u();void stat_o();void regist();void stat();2、各功能模塊函數(shù)部分:( 1)輸入模塊 需求分析 對(duì)信息進(jìn)行輸入。流程圖 :輸入用戶要輸入客戶記錄的個(gè)數(shù)ni 從 0 到 n-1 調(diào)用輸入函數(shù)input(i)i! =0Y保存調(diào)用函數(shù)save( n)輸入模塊流程圖6程序void regist()/* 注冊(cè)函數(shù) */int n,m,i,
9、j;printf("tHow many new customs?t");scanf("%d",&n);printf("tHow many rooms they want?");scanf("%d",&m);for(i=r;i<r+m;i+)puts("ntRoom_ID:t");scanf("%d",&roomi.room_ID);puts("ntTel:t");scanf("%s",roomi.tel);
10、puts("ntPrice:t");scanf("%d",&roomi.price);roomi.sign=1;for(j=p;j<p+n;j+)puts("ntName:t");scanf("%s",roomi.client_);puts("ntSex(1 for men | 0 for women):t");scanf("%d",&roomi.client_listj.sex); puts("ntAge:t")
11、;scanf("%d",&roomi.client_listj.age); puts("ntID_card:t");scanf("%s",roomi.client_listj.ID_card); puts("ntYear:t");scanf("%d",&roomi.client_listj.year); puts("ntMonth:t");scanf("%d",&roomi.client_listj.month); puts(&qu
12、ot;ntDate:t");scanf("%d",&roomi.client_listj.date); r=r+m;p=p+n;save();menu();( 2)統(tǒng)計(jì)模塊 需求分析 該模塊的功能是顯示所有客戶記錄信息。流程圖 :顯示客戶記錄(10 個(gè)一屏)7按任意鍵顯示下一屏按任意鍵返回主菜單統(tǒng)計(jì)模塊流程圖程序void stat()/* 統(tǒng)計(jì)函數(shù) */int n,m;doputs("tt*MENU*n");puts("tttt1).Statistics one monthn");puts("tttt2).
13、Statistics using roomn");puts("tttt3).MENU()");puts("tt*n");printf("ttPlease choice your number(1-3): bb");scanf("%d",&n);if(n<1&&n>3)m=1;getchar();else m=0;while(m=1);switch(n)case 1:stat_o();break;case 2:stat_u();break;case 3:menu();vo
14、id stat_o()/*統(tǒng)計(jì)人數(shù) */int j,i,n,l;8int s=0;puts("Please input the month you want to statistics:");scanf("%d",&n); load_room();for(i=0;i<r;i+)for(j=0;j<p;j+)if(roomi.client_listj.month=n) s=s+1;printf("There are %d customer this month",s); puts("nnWhat you w
15、ant to do?n"); puts("1).Statistics againt2).backn"); scanf("%d",&l);switch(l)case 1:stat_o();break;case 2:stat();void stat_u()/*統(tǒng)計(jì)使用中的房間 */int j,l,s=0;load_room();for(j=0;j<p;j+) if(roomj.sign=1) s+=1;printf("There are %d rooms in use",s);puts("nnWhat y
16、ou want to do?n");puts("1).Statistics againt2).backn");scanf("%d",&l);switch(l)case 1:stat_u();break;case 2:stat();printf_p(int i,int j)/*顯示個(gè)人信息 */printf("name:");puts(roomi.client_);printf("nsex:%dn",roomi.client_listj.sex);printf("nag
17、e:%dn",roomi.client_listj.age);puts("nID_card:");printf("%s",roomi.client_listj.ID_card);printf("nyear:%dn",roomi.client_listj.year);printf("nmonth:%dn",roomi.client_listj.month);printf("ndate:%dn",roomi.client_listj.date);printf("nRoom_ID:
18、%dn",roomi.room_ID);printf("nTel:%sn",roomi.tel);9printf("nPrice:%dn",roomi.price);( 3)查找模塊查找模塊是否找到客戶記錄YN輸入一整型數(shù)值提示沒有找到1,2,還是123按身份證查找調(diào)按房間號(hào)查找,返回主菜單用 Search1()調(diào)用 Search2()查找模塊流程圖程序 :void search()/*查找函數(shù) */int n,m;doputs("nntt*MENU*n");puts("tt1).Search someone ha
19、d erev lived heren");puts("tt2).Search someday n");puts("tt3).MENU()");puts("tt*n");printf("ttPlease choice your number(1-3): bb");scanf("%d",&n);if(n<1&&n>3)10m=1;getchar();else m=0;while(m=1);switch(n)case 1:search_one();brea
20、k;case 2:search_day();break;case 3:menu();void search_one()/*查找個(gè)人 */int i,j,w=0,l,m,n;char s20;printf("Please input the namen");scanf("%s",s);load_room();for(i=0;i<r;i+)for(j=0;j<p;j+)if(strcmp(roomi.client_,s)=0) w=1,m=i,n=j;if(w=1)printf_p(m,n);else printf("
21、;nThere is no record heren");puts("What do you want to do?n");puts("1).search againt2).backn");scanf("%d",&l);switch(l)case 1:search_one();break;case 2:search();void search_day()/*查詢某日的使用情況*/int i,j,l,m,n,a,b,c,w=0;printf("nPlease input the day you want to
22、 search");printf("nYear:"); scanf("%d",&a);printf("nMonth:"); scanf("%d",&b);printf("nDate:"); scanf("%d",&c);load_room();for(i=0;i<p;i+)11for(j=0;j<r;j+)if(roomi.client_listj.date=c)&&(roomi.client_listj.mont
23、h=b)&&(roomi.cli ent_listj.year=a) w=1,m=i,n=j,printf_p(m,n);if(w=0)printf("NO record this dayn");puts("What you want to do?n");puts("1).search againt2).backn");scanf("%d",&l);switch(l)case 1:search_day();break;case 2:search();( 4)修改模塊 需求分析 該模塊的功能是
24、插入客戶記錄信息并且不能覆蓋原有客戶信息。流程圖 插入模塊調(diào)用加載函數(shù)讓用戶輸入要插入的客戶信息個(gè)數(shù)調(diào)用整條信息輸入函數(shù)用戶作出選擇,輸入1or2121還是 21 瀏覽全部2返回主菜單修改模塊流程圖程序 :void modify()/*修改函數(shù)*/int n,m;doputs("tt*MENU*n");puts("tttt1).modify one peoplen");puts("tttt2).modify one dayn");puts("tttt3).MENU()");puts("tt*n"
25、);printf("ttPlease choice your number(1-3): bb");scanf("%d",&n);if(n<1&&n>3)m=1;getchar();else m=0;while(m=1);switch(n)case 1:modify_one();break;case 2:modify_day();break;case 3:menu();void modify_one()/*修改個(gè)人信息*/int i,j,m,n,w=0,l;char s20;puts("ttPlease inp
26、ut the name");scanf("%s",s);load_room();for(i=0;i<r;i+)13for(j=0;j<p;j+)if(strcmp(roomi.client_,s)=0) w=1,m=i,n=j; if(w=1)printf_p(m,n);else printf("nThere is no record heren");modify_s(m,n);save();puts("What you want to do?n");puts("1).Modify
27、againt2).backn");scanf("%d",&l);switch(l)case 1:modify_one();break;case 2:modify();void modify_s(int i,int j)/*修改執(zhí)行項(xiàng) */int a,q;char s20,b15;printf("nChoice the title you want to modifyn");puts("1).Name2).sex3).age4)ID_card5).year6).month7).date8).room_ID 9)tel 10).p
28、rice11).modify nonen");printf("Please choice your number(1-10): bb");scanf("%d",&q);switch(q)case1:printf("Pleaseinputnewnamen");scanf("%s",s);strcpy(roomi.client_,s);break;case2:printf("Pleaseinputnewsexn");scanf("%d",&a
29、mp;a);roomi.client_listj.sex=a;break;case3:printf("Pleaseinputthenewagen");scanf("%d",&a);roomi.client_listj.age=a;break;case4:printf("PleaseinputnewID_cardn");scanf("%s",s);strcpy(roomi.client_listj.ID_card,s);break;case5:printf("Pleaseinputnewyearn&
30、quot;);scanf("%d",&a);roomi.client_listj.year=a;break;case6:printf("Pleaseinputthenewmonthn");scanf("%d",&a);roomi.client_listj.month=a;break;case7:printf("Pleaseinputthenew14daten");scanf("%d",&a);roomi.client_listj.date=a;break;case 8:p
31、rintf("Please input the new room_IDn");scanf("%d",&a);roomi.room_ID=a;break;case 9:printf("Please input the new teln");scanf("%s",b);strcpy(roomi.tel,b);break;case 10:printf("Please input the new pricen");scanf("%d",&a);roomi.price=
32、a;break;case 11:modify();void modify_day()/*修改某日信息*/int i,j,l,a,b,c,w=0,m,n;puts("ttPlease input the date");puts("nYear:");scanf("%d",&a);puts("nMonth:");scanf("%d",&b);puts("nDate:");scanf("%d",&c);load_room();for(i=0
33、;i<p;i+)for(j=0;j<r;j+)if(roomi.client_listj.date=c)&&(roomi.client_listj.month=b)&&(roomi.cli ent_listj.year=a) w=1,m=i,n=j;if(w=1)printf_p(m,n);else printf("NO record this dayn");modify_s(m,n);save();puts("What you want to do?n");puts("1).modify again
34、t2).backn");scanf("%d",&l);switch(l)case 1:modify_day();break;case 2:menu();153、公共函數(shù)部分:( 1)保存函數(shù) save()void save()/*保存函數(shù) */FILE*fp;int i,j;if(fp=fopen("room.txt","w")=NULL)printf("nCannot open filen");return NULL;for(i=0;i<r;i+)for(j=0;j<p;j+)fpr
35、intf(fp,"%d,%s,%d,%d,%s,%d,%d,%s,%d,%d,%d",roomi.room_ID,roomi.tel,roomi.price,roomi.sign,roomi.client_,roomi.client_listj.sex,roomi.client_listj.age,room i.client_listj.ID_card,roomi.client_listj.year,roomi.client_listj.month,roomi.client_listj. date);fclose(fp);return 1;( 2)加載函
36、數(shù)load_room() 說明 :該函數(shù)可以用來加載所有記錄,并且可以返回所有記錄的個(gè)數(shù)。void load_room()/*加載函數(shù) */FILE *fp;struct hotel roomN;int i,j;if(fp=fopen("room.txt","r")=NULL)printf("nCannot open filen");16return 0;for(i=0;!feof(fp);i+)for(j=0;!feof(fp);j+)fscanf(fp,"%d,%s,%d,%d,%s,%d,%d,%s,%d,%d,%d&
37、quot;,&roomi.room_ID,roomi.tel,&roomi.price,&roomi.sign,roomi.client_,&roomi.client_listj.sex,&roomi.client_listj.age,roomi.client_listj.ID_card,&roomi.client_listj.year,&roomi.client_listj.month,&roomi.client_listj.date);fclose(fp);r=i;p=j;( 3)一個(gè)任務(wù)結(jié)束時(shí)的選擇函數(shù)printf_back()void printf_back()int k,w;void browse();printf("nntSuccessful-.nn");printf("What do you want to do?nnt1).Browse all nowt2).Back: bb"); scanf("%d",&w);if(w=1)br
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 二零二五年工廠股權(quán)轉(zhuǎn)讓與產(chǎn)業(yè)園區(qū)配套設(shè)施建設(shè)合同3篇
- 個(gè)人貸款延期合同書2024版標(biāo)準(zhǔn)格式版B版
- 二零二五年度啤酒節(jié)場(chǎng)地租賃合同(含設(shè)備安裝與維護(hù)服務(wù))3篇
- 2025年度朋友合資經(jīng)營(yíng)兒童游樂場(chǎng)合同4篇
- 二零二五版綠色建筑項(xiàng)目材料集中采購(gòu)合同3篇
- 二零二五年度內(nèi)墻膩?zhàn)赢a(chǎn)品責(zé)任保險(xiǎn)合同
- 2025年度生態(tài)旅游區(qū)臨設(shè)轉(zhuǎn)讓及生態(tài)保護(hù)合同4篇
- 2025版土地居間業(yè)務(wù)規(guī)范化合同書(正規(guī)范本)6篇
- 二零二五年度啤酒產(chǎn)品節(jié)慶活動(dòng)專用代理合同
- 二零二五年度二手車買賣及二手車評(píng)估合同協(xié)議2篇
- 2023年廣東省公務(wù)員錄用考試《行測(cè)》真題及答案解析
- 2024年公證遺產(chǎn)繼承分配協(xié)議書模板
- 燃?xì)饨?jīng)營(yíng)安全重大隱患判定標(biāo)準(zhǔn)課件
- 深圳小學(xué)英語單詞表(中英文)
- 護(hù)理質(zhì)量反饋內(nèi)容
- 山東省濟(jì)寧市2023年中考數(shù)學(xué)試題(附真題答案)
- 抖音搜索用戶分析報(bào)告
- 鉆孔灌注樁技術(shù)規(guī)范
- 2023-2024學(xué)年北師大版必修二unit 5 humans and nature lesson 3 Race to the pole 教學(xué)設(shè)計(jì)
- 供貨進(jìn)度計(jì)劃
- 彌漫大B細(xì)胞淋巴瘤護(hù)理查房
評(píng)論
0/150
提交評(píng)論