計算機(jī)技術(shù)基礎(chǔ)-c語言-課程設(shè)計-花店經(jīng)營管理系統(tǒng)_第1頁
計算機(jī)技術(shù)基礎(chǔ)-c語言-課程設(shè)計-花店經(jīng)營管理系統(tǒng)_第2頁
計算機(jī)技術(shù)基礎(chǔ)-c語言-課程設(shè)計-花店經(jīng)營管理系統(tǒng)_第3頁
計算機(jī)技術(shù)基礎(chǔ)-c語言-課程設(shè)計-花店經(jīng)營管理系統(tǒng)_第4頁
計算機(jī)技術(shù)基礎(chǔ)-c語言-課程設(shè)計-花店經(jīng)營管理系統(tǒng)_第5頁
已閱讀5頁,還剩12頁未讀 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

計算機(jī)技術(shù)基礎(chǔ)課程設(shè)計

C語言

設(shè)計報告

題目:花店經(jīng)營管理系統(tǒng)

一.選題背景

本例實現(xiàn)了一個花店經(jīng)營的管理系統(tǒng),在經(jīng)營的過程中,必需

對花的庫存量,銷售量,剩余量以及花的種類,單價,顏色,名字

等,有系統(tǒng)的管理。本程序定義了一個結(jié)構(gòu)數(shù)組,并運(yùn)用了一個主

函數(shù)調(diào)用五個函數(shù)以實現(xiàn)整個花店的經(jīng)營和管理。

二.設(shè)計思想:

編程思路:首先在程序開始處,引入了頭文件,可以直接調(diào)用

函數(shù),然后對花的種類和五項命令進(jìn)行了宏定義,接著枚舉類型定

義了花的顏色,定義了結(jié)構(gòu)體數(shù)組,并且編寫

了“enter_data()","put_data?!?,“buy()”,"find?!绷?/p>

changecmdOv五個子函數(shù),最后在mian函數(shù)的內(nèi)部對各個子函數(shù)

進(jìn)行調(diào)用,實現(xiàn)綜合管理。

三.主要解決問題的方法及技術(shù)關(guān)鍵:

1.運(yùn)用指針定義了五項命令,分別指向五個函數(shù),便于調(diào)用。

2.運(yùn)用了for,ifelseif,while,switch—case

用來控制程序的流程。

主函數(shù)流程圖

’7T-^

系統(tǒng)初始化

輸出花的各項值

輸出花的各

switch.相提所

出口

Enter()流

五.程序清單

ftinclude〃stdio.h〃

#include"stdlib.h〃

ftinclude"string.h〃

ftinclude〃dos.h〃

#defineSIZE8

#defineCMDSIZE5

typedefenum/*枚舉類型定義*/

(

red,white,yellow,purple,orange

}COLOR;

typedefstruct/*結(jié)構(gòu)體定義*/

(

charname[20];

COLORcolor;

floatrate;

intamount;

}FLOWER;

char*Dcmd口={〃buy〃,"put”,〃look〃,〃find〃,"help"};

/*定義了5項命令的指針類型*/

voidenter_data(FLOWERflower[]);/*定義庫存輸入函數(shù)*/

floatbuy(FLOWERflower[]);/*定義銷售函數(shù)*/

voidput_data(FLOWERflower:]);/*定義庫存輸出函數(shù)*/

voidfindflower(FLOWERflower口);/*定義查詢函數(shù)*/

intchangecmd(charcmd[]);/*定義命令解釋函數(shù)*/

voidmain()

(

FLOWERflower[SIZE];

floatprice;

charcmd[5]={'\0','\0','\0','\0','\0';;

charexits[5]=,zquit,z;

intrecmd=0;

inti;

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

(

memset(flower[i].name,0,20);/*成員設(shè)置,各類型初始化*/

flower[i].rate=0;

flower[i].amount=0;

flower[i].color=white;

)

printf(〃花店經(jīng)營管理系統(tǒng)\n〃);

printf(zz\nYoucaninput'buy'look'put'help'find':\n〃);

while(l)/*命令轉(zhuǎn)換,把字符轉(zhuǎn)換為數(shù)字*/

scanf(〃%s〃,cmd);

if(strcmp(cmd,exits)==0)

exit(1);

recmd=changecmd(cmd);

swit.ch(recmd)

(

case0:

printf(z,abadcommandpleaseinputacorrcetcmd\n");/*

輸入了錯誤信息的提示*/

break;

case1:

price=buy(flower);

if(price==0)

printf(〃\nSorry,buyerror");

else

printf(,z\nOK,Pleasepaymoney%f\n,z,price);

break;

case2:

enter_data(flower);

break;

case3:

putdata(flower);

break;

case4:

findflower(flower);

break;

case5:

printf(z/\nYoucaninput

,buy,,'look','put',,help,,'find,:\n〃);

break;

j

)

)

/*命令解釋函數(shù)*/

/*該函數(shù)處理接收到的命令通過與命令數(shù)組里的預(yù)定義命令比較返回命

令在數(shù)組中的位置本/

intchangecmd(charcmd[])

{

inti=0;

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

(

if(strcmp(cmd,Dcmd[i])==0)

returni+1;

)

return0;

}

/*庫存輸入函數(shù)*/

/*該函數(shù)接受鍵盤輸入把輸入數(shù)據(jù)與庫存對應(yīng)*/

voident.erdata(FLOWERflower[])

(

inti,flag;

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

(

printf(z,Pleaseentertheflowers:\nz,);

printf(z,F(xiàn)lowernameis:\n〃);

scanfflower[i].name);

printf(Z/Flowerrateis:\n〃);

scanf&flower[i].rate);

printf("Floweramountis:\n〃);

scanf(〃%d〃,&flower[i].amount);

flag=l;

while(flag)/*接受用戶選擇的顏色*/

(

printf(//0->red\tl->white\t2->yellow\t3->purple\t4->orante\n/,);

printf("Pleasechooseacolor:\n,z);

scanf(〃96d〃,&flower[i].color);

if(flower[i].color>=0&&flower[i].color〈二4)

flag=0;

else

printf(z,Not.havethiscolor\nz,);

)

)

)

/*輸出現(xiàn)有庫存的鮮花數(shù)據(jù)的函數(shù)定義*/

voidput_data(FLOWERflower[])

I

inti;

printf(,z\nNameColorRateAmount\nz,);

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

(

printf(級-12s〃,flower[i].name);

switch(flower[i].color)

(

casered:

printf(〃%-8s〃,"red");

break;

casewhite:

printf(繪-8s〃,“white");

break;

caseyellow:

printf-8s〃,“yellow");

break;

casepurple:

printf(〃%-8s〃,“purple");

break;

caseorange:

printf(〃%-8s〃,“orange");

break;

)

printf(〃%-10.2f%-10d\n,/,flower[i].rate,flower[i].amount);

)

)

/*詢問用戶購買的鮮花的種類和株的數(shù)量,計算總的價格的函數(shù)定義*/

floatbuy(FLOWERflower[])

(

inti;

charname[20];

COLORcolor;

floatrate,price;

intamount,flag;

printf(,z\nPleaseenternameandrateyouwanttobuy:\n〃);

/*輸出需要的鮮花的名字和價格*/

scanf(〃%s%f〃,name,Srate);

flag=1;

while(flag)/*客戶購買花的情況*/

(

printf(,z0->red\tl->white\t2->yellow\t3->purple\t4->orante\nz,);

printf(z,Pleasechooseacolor:\n,z);

scanf("%d”,&color);

if(color>=0&&co1or<=4)

flag=0;

else

printf(z,Nothavethiscolor\n,");

)

printf(,zPleaseamountyouwanttobuy:\n〃);

/*輸出需要的花的數(shù)量*/

scanf(級d〃,&amount);

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

if(flower[i].rate==rate&&strcmp(flower[i].name,name)==0&&flowe

r[i].color==color)

break;

}

if(i==SlZE)

(

printf(z,\nNotfountthefloweryoubuy\n〃);

/*沒有要買的花*/

price=0;

)

elseif(flower[i].amountVamount)/*所購花數(shù)量不夠*/

(

printf(/z\nAmountnotenought'n");

price=0;

)

else

(

flower[i].amount二flower[i].amount-amount;

price=flower[i].rate*amount;/*找到,剩余數(shù)量夠,可以買花,

并計算總價格*/

)

returnprice;

)

/*對于庫存鮮花的的查詢方式的定義*/

voidfindflower(FLOWERflower[])

inti,rcmd;

charname[20];

floatrate;

COLORcolor;

printf(z,Pleasechooseanumber:\n〃);/*輸出查詢的方式*/

printf(,,0->findasname\tl->findasrate\t2->findascolor'd');

scanf(〃96d〃,&rcmd);

switch(rcmd)

(

case0:/東按花名查詢*/

printf(^Inputaflowername:\n,z);

scanf(,z%s,z,name);

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

(

if(flower[i].name==name)

printf(,z%s\t%d\t%f\t%d\n,z,flower[i].name,flower[i].color,flowe

r[i].rate,flower[i].amount);

}

break;

case1:/*按數(shù)量查詢*/

printf(,zInputaflowerrate:\n,z)

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論