c語言購物系統(tǒng)_第1頁
c語言購物系統(tǒng)_第2頁
c語言購物系統(tǒng)_第3頁
c語言購物系統(tǒng)_第4頁
c語言購物系統(tǒng)_第5頁
已閱讀5頁,還剩9頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

1、C語言課程設(shè)計報告班學(xué)號: *姓名: *指導(dǎo)老師: *日期: *中國地質(zhì)大學(xué)(武漢)計算機學(xué)院一、題目要求系統(tǒng)主要功能模塊:1,實現(xiàn)系統(tǒng)內(nèi)制卡,發(fā)卡功能。2,實現(xiàn)系統(tǒng)內(nèi)購物卡帳戶及相關(guān)帳戶管理。3,實現(xiàn)購物卡交易和合法性檢查。4,實現(xiàn)購物卡交易積分功能。5,實現(xiàn)購物卡報表功能。6,數(shù)據(jù)以文件形式存儲。提示:制卡:指申請一個購物卡,但還沒有使用。發(fā)卡:指該卡已經(jīng)起用。實現(xiàn)卡交易:指從卡中消費掉一定金額。二、需求分析根據(jù)題目要求,由于購物卡信息是存放在文件中,所以應(yīng)提供文件的輸入、輸出等操作;在程序中需瀏覽購物卡的信息,應(yīng)提供報表、查詢等操作;另外還應(yīng)提供鍵盤式選擇菜單實現(xiàn)功能選擇。三、總體設(shè)計根

2、據(jù)需求分析,可以將系統(tǒng)分為五大模塊:制卡、發(fā)卡、登陸、報表、積分。購物卡管理系統(tǒng)制卡模塊發(fā)卡模塊登錄模塊積分模塊報表模塊查詢儲蓄修改密碼消費四、詳細(xì)設(shè)計1、主函數(shù)將main()函數(shù)體內(nèi)的界面選擇部分語句單獨抽取出來作為一獨立函數(shù),目的在于系統(tǒng)執(zhí)行完每部分功能模塊后能夠方便返回到系統(tǒng)界面。void menu()int v,w1;doprintf("tt*MENU*nn");printf("tttt 1.card-maden");printf("tttt 2.card-lifen");printf("tttt 3.card-en

3、tern");printf("tttt 4.card-browsen");printf("tttt 5.exitn");printf("nntt *n");printf("Choice your number(1-5):bb");scanf("%d",&v);if(v<1|v>5) w1=1;getchar();else w1=0;while(w1=1);switch(v)case 1:made();break; case 2:life();break; case

4、3:enter();break; case 4:browse();break; case 5:exit(0); 2、各功能模塊設(shè)計(1)制卡模塊【數(shù)據(jù)結(jié)構(gòu)】struct credicard int number;char name20;char ID20;char word8;int flag;float account; int integal; cardM;/*cardM中每個數(shù)組元素對應(yīng)一個運動員信息* /【程序】void made() int i;char h20;doprintf("nnt Input your number:<ttt>bbbbbbb"

5、);scanf("%s",h);if(strlen(h)!=6)printf("nnntt*Wrong!Input again*nn");continue;for(i=0;i<n;i+)if(strcmp(cardi.ID,h)=0)printf("nntt*The number exist,input again*nn");break;while(strlen(h)!=6)|strcmp(cardi.ID,h)=0); cardn.number=n;strcpy(,"*");strcpy

6、(cardn.ID,h);strcpy(cardn.word,"000000");cardn.flag=0;cardn.account=0.00;egal=0; printf("nnntt*The card is made!*nn"); print_one(n);n+; add();menu();print_one(n):顯示一張卡信息的函數(shù)。【程序】void print_one(int j) printf("n|-|-|-|-|-|-|"); printf("n|NO. | name | ID |flag

7、| account | integal |"); printf("n|-|-|-|-|-|-|"); printf("n|%4d|%20s|%20s|%4d|%10.2f|%10d|", cardj.number,,cardj.ID,cardj.flag,cardj.account,egal); printf("n|-|-|-|-|-|-|");(2)發(fā)卡模塊void life() int k=-1;char h20;if(n=0) printf("nntt*Make card

8、 first*n");elseprintf("nnt Input your applied number:<ttt>bbbbbbb");scanf("%s",h);k=search(h);if(k=-1)printf("nnttt*Wrong number!*n");elseif(cardk.flag=1)printf("nntt*Life already!*n");else huo(k);menu();huo(k):激活一張卡的函數(shù)。void huo(int k) char m20,p8;i

9、nt x,w2;do printf("nntt Life? (1) Yes (2) No n"); printf("ntt Chioce your number:< >bb"); scanf("%d",&x); if(x<1|x>2) w2=1;getchar(); else w2=0;while(w2=1);if(x=1)printf("nnttInput your name:<ttt>bbbbbbbbbbbbbbbbbbbb");scanf("%s"

10、;,m);strcpy(,m);printf("nnttInput six-number code :< >bbbbbbb");scanf("%s",p); strcpy(cardk.word,p); cardk.flag=1; printf("nnntt*Life!*nn");print_one(k); add();(3)登陸模塊void enter() int k=-1;char h20;if(n=0) printf("nntt*Make card first*n");elsep

11、rintf("nntInput your applied number:<ttt>bbbbbbb");scanf("%s",h);k=search(h);if(k=-1)printf("nnttt*Wrong number!*n");elseif(cardk.flag=0)printf("nntt*LIFE FIRST!*n");elsehedui(k);menu();hedui(k):登陸信息。void hedui(int k) int c=0,w3=0;char p8;do printf("

12、;nntt*Input your code:< >bbbbbbb");scanf("%s",p); if(strcmp(cardk.word,p)!=0) printf("nntt*Wrong code!*n"); c+; continue;elseprintf("nntt*Right code!*n");w3=1; menu1(k);while(w3=0&&c<3);子菜單設(shè)計如下:void menu1(int k) int v,w4; printf("tt*MENU*nn&qu

13、ot;);printf("tttt 1.Inquiren");printf("tttt 2.Depositn");printf("tttt 3.fetchn");printf("tttt 4.change coden");printf("tttt 5.back to menun");printf("nntt *n");printf("Choice your number(1-5):< >bb");scanf("%d",&am

14、p;v);if(v<1|v>5)w4=1;getchar();else w4=0;while(w4=1);switch(v)case 1:stat_one(k);break;case 2:deposit(k);break;case 3:fetch(k);break;case 4:change(k);break; case 5:menu();子模塊設(shè)計如下查詢模塊:void stat_one(int k)printf("nntt*Operate successfully!*");print_one(k);menu1(k);儲蓄模塊void deposit(int

15、k)float a=0.00;printf("nnttInput your amount:<tt>bbbbbbbbbbb");scanf("%f",&a);cardk.account+=a; printf("nntt*deposit successfully!*");print_one(k);add();menu1(k); 消費模塊:void fetch(int k) float b=0.00;printf("nnttInput your amount:<tt>bbbbbbbbbbb"

16、;);scanf("%f",&b);if(b>cardk.account)printf("nntt*Remaining sum is not enough !*");else cardk.account-=b; egal=b; printf("nntt*Your patronage !*"); print_one(k); add();menu1(k);修改密碼模塊:void change(int k) char a8,b8;printf("nnttInput new six-number co

17、de:< >bbbbbbb");scanf("%s",a);printf("nttInput new code again:< >bbbbbbb");scanf("%s",b);if(strcmp(a,b)=0)printf("nntt*Code change!*");add();elseprintf("nnttDifferent codes,code change failed!");menu1(k);(4)報表模塊:void browse() int i;

18、if(n=0) printf("nntt*Make card first!*"); else printf("nntt*Operate successfully!*n"); printf("n|-|-|-|-|-|-|"); printf("n|NO. | name | ID |flag| account | integal |"); printf("n|-|-|-|-|-|-|"); for(i=0;i<n;i+) printf("n|%4d|%20s|%20s|%4d|%10

19、.2f|%10d|", cardi.number,,cardi.ID,cardi.flag,cardi.account,egal); printf("n|-|-|-|-|-|-|"); menu( ); 3、公共函數(shù)(1)保存函數(shù)void add() int i;FILE *fp;if(fp=fopen("score.txt","wb")=NULL)printf("tt Can not open the file n");return;for(i=0;i<n;i+)if(fwrite(&ca

溫馨提示

  • 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

提交評論