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

下載本文檔

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

文檔簡介

1、精品文檔C語言課程設(shè)計報告班學號: 姓名:*指導老師:*日期:*中國地質(zhì)大學(武漢)計算機學院. 。1歡迎下載精品文檔8 歡迎下載 。一、題目要求系統(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ù)題目要求,由于購物卡信息是存放在文件中,所以應提供文件的輸入、 輸出等操作;在程序中需瀏覽購物卡的信息,應提供報表、查詢等操作;另外還應提

2、供鍵盤式選擇菜單實現(xiàn)功能選擇。三、總體設(shè)計根據(jù)需求分析,可以將系統(tǒng)分為五大模塊:制卡、發(fā)卡、登陸、報表、積分。四、詳細設(shè)計1、主函數(shù)目的在于系統(tǒng)執(zhí)行將 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-enter

3、n");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 3:ente

4、r();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ù)組元素對應一個運動員信息* /【程序】void made()int i;char h20;doprintf("nnt Input your number:<ttt>bbbbbbb");scanf(&

5、quot;%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)again*printf("nntt*nn");*Thenumberexist,inputbreak;while(strlen(h)!=6)|strcmp(cardi.ID,h)=0);cardn.number=n;strcpy(,"*");strcpy(cardn.ID,h)

6、;strcpy(cardn.word,"000000");cardn.flag=0;cardn.account=0.00;egal=0;printf("nnntt*Thecardismade!*nn");print_one(n);n+;add();menu();print_one(n) :顯示一張卡信息的函數(shù)?!境绦颉縱oid print_one(int j)printf("n|");printf("n|NO. | name | ID |flag| account | integal |");|p

7、rintf("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* else |*Makecard first*n");printf("nnt Input your ap

8、plied number:<ttt>bbbbbbb");scanf("%s",h);k=search(h);if(k=-1)printf("nnttt*Wrongnumber!*n");else if(cardk.flag=1)printf("nntt*Life already!*n");else huo(k);menu();huo(k) :激活一張卡的函數(shù)。void huo(int k)char m20,p8;int x,w2;doprintf("nntt Life? (1) Yes (2) No n

9、");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("nnttInputyourname:<ttt>bbbbbbbbbbbbbbbbbbbb"); scanf("%s",m); strcpy(,m); printf("nnttInput six-nu

10、mber 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*Makecard first*n");elseprintf("nntInput your applied number:<ttt>bbbbbbb

11、"); scanf("%s",h);k=search(h);if(k=-1)number!*printf("nnttt*n");*Wrong精品文檔else9 歡迎下載if(cardk.flag=0)printf("nntt*LIFE FIRST!*n");elsehedui(k);menu();hedui(k) :登陸信息。void hedui(int k)int c=0,w3=0;char p8;doprintf("nntt*Input your code:< >bbbbbbb");sca

12、nf("%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");printf("tttt 1.Inquiren");printf("

13、;tttt 2.Depositn");printf("tttt 3.fetchn");。精品文檔printf("tttt 4.change coden");printf("tttt 5.back to menun");11 歡迎下載 。printf("nntt*n");printf("Choice your number(1-5):< >bb");scanf("%d",&v);if(v<1|v>5)w4=1;getchar(); el

14、se 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 k)float a=0.00;printf("nnttInput yo

15、ur 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");scanf("%f",&b);if(b>car

16、dk.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 code:< >bbbbbbb");scanf("

17、%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;if(n=0)printf("nntt*Make card f

18、irst!*"); 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.2f|%10d|", cardi.number,,cardi.ID,cardi.flag,c

19、ardi.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(&cardi,sizeof(struct credicard),1,fp)!=1)printf("tt Fi

20、le write error n");return;fclose(fp);printf("nnntt*Keep!*n");( 2 )查找函數(shù)int search(char h20)int i,k=-1;for(i=0;i<n;i+)if(strcmp(cardi.ID,h)=0)k=i; return(k);五、運行結(jié)果12 歡迎下載。精品文檔18歡迎下載(1)主菜單(2)制卡模塊:輸入卡號(3)制卡成功(5)發(fā)卡成功(6)登錄模塊Input your applied numbei*:<000002>MWMMMMMinput your code:

21、<0000B>codef ><發(fā):*1(*XMXXMHHMXXXHWMXXMXXHXfIEhIU H X X M M * X N X NX X XX X XX X X M1.1 nquire2 .Deposit3 .fetch4 .change code5 .back to menuho ice yoiAP numbei*4i-5> = < >(7)儲畜成功I npiit </ouir amount 200I1NO.Iliname11IDi1flal_ 1Iiaccountiflintegal.11 - 1list1100000211011 12

22、00.80 01 _IIHMHXMHMMH 內(nèi)1 RO3 it SUCC BSsf 111 llj* MKXMxHXXHXXWJIXKHWJtXKMKee口 t * * XKXXHXXHXX*1.Inquire2 .Deposit3 .fetch4change code5 . baclc to menu|Cho ice youi* numbe產(chǎn)<1 =5>:<.(8)修改密碼Input new six-number code =<000001>Input nev codle a9ain : <0140001 >苒n*茵苒*苒Cnde cBadgef *x苒*Nx>ofK甘苒苒甘N甘苒X 苒*茵Ke- P t t f X*苒苒MNXXHXMJf * Jt* * Jt * *)<* JOCK *MENU1_Inquire6 . Deposit3«Fetch4_change code Sr back to menu.Cho ice your nur)ber<l-5 > : <

溫馨提示

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

評論

0/150

提交評論