活期儲蓄賬目管理._第1頁
活期儲蓄賬目管理._第2頁
活期儲蓄賬目管理._第3頁
活期儲蓄賬目管理._第4頁
活期儲蓄賬目管理._第5頁
已閱讀5頁,還剩22頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

1、數(shù)據(jù)結(jié)構(gòu)課程設(shè)計題目:活期儲蓄賬目管理學(xué)院:班級:學(xué)生姓名:學(xué)生學(xué)號:指導(dǎo)教師:2013 年11月27 日課程設(shè)計任務(wù)書姓名班級學(xué)號設(shè)計題目活期儲蓄賬目管理理論要點1. 活期儲蓄處理中,儲戶開戶、銷戶、存入、支出活動頻繁,系 統(tǒng)設(shè)計要求:2. 能比較迅速地找到儲戶的帳戶,以實現(xiàn)存款、取款記賬;并能 實現(xiàn)排序。3. 能比較簡單,迅速地實現(xiàn)插入和刪除,以實現(xiàn)開戶和銷戶的需 要。設(shè)計目標1. 代替營業(yè)員進行許多繁雜的手動操作。2. 給用戶帶來了很大的方便。3. 節(jié)省許多人力資源。4. 提高人們的工作效率。研究方法 步驟1. 設(shè)計程序流程圖2. 編寫源程序3. 編譯運行,對指定文件進行編碼譯碼預(yù)期結(jié)果

2、實現(xiàn)對既定文件的讀入,編碼壓縮后存入另一文件,調(diào)出編碼后 的文件進行譯碼輸出并存入新文件。計劃與進 步的安排1. 搜集資料,理解原理,分析已有的編碼1天2. 分模塊分析,畫出實驗流程圖1天3. 編寫源代碼2天4. 編譯運行,對既定文件進行編碼譯碼2天5. 實驗總結(jié)1天摘要1題目分析目錄錯誤!未定義書簽錯誤!未定義書簽2概要設(shè)計 23詳細設(shè)計 24調(diào)試設(shè)計 55用戶使用說明 66 測試結(jié)果 67 結(jié)論體會 8參考文獻 89源程序9摘要隨著計算機的普及,現(xiàn)代人越來越多的想到用計算機來代替許多人做的事 情。從而提高辦事效率,使經(jīng)濟收入更加可觀,從而就產(chǎn)生了計算機這門課程。 隨著信息技術(shù)的飛速發(fā)展,大

3、量信息需要傳輸,傳輸信息就要先經(jīng)過編碼,然后 再譯碼,可見編碼技術(shù)的提高對整個信息產(chǎn)業(yè)有著舉足輕重的作用。而計算機主要是通過程序來實現(xiàn)各種事情的,再者程序也必須通過各種算法才能達到存儲各 種數(shù)據(jù),所以數(shù)據(jù)結(jié)構(gòu)這門課程就應(yīng)運而生。本課程設(shè)計主要是用數(shù)據(jù)結(jié)構(gòu)編寫 關(guān)于活期儲蓄賬目管理的算法,來達到活期儲蓄賬目管理的目的。關(guān)鍵詞:編碼 存儲 活期儲存賬目管理錯誤!未定義書簽數(shù)據(jù)結(jié)構(gòu)課程設(shè)計1題目分析活期儲蓄管理系統(tǒng)用戶通過該系統(tǒng)可以進行存款、取款、銷戶等業(yè)務(wù)。該系 統(tǒng)在金融業(yè)給人民帶來了很大的方便,系統(tǒng)開發(fā)成功后,一旦應(yīng)用于銀行領(lǐng)域, 會給管理員與用戶帶來很大的方便,其主要作用具體如下:1)、可以代

4、替營業(yè)員進行許多繁雜的手動操作。2)、給用戶帶來了很大的方便。3 )、可以節(jié)省許多人力資源。4 )、可以提高人們的工作效率。活期儲蓄賬目管理系統(tǒng)主要是由于在活期儲蓄處理中,儲戶開戶、銷戶、存入、支出活動頻繁,為實現(xiàn)儲戶的各種操作而設(shè)計的, 本課程設(shè)計的主要功能包 括實現(xiàn)儲戶開戶、銷戶、存入、支出等活動,為了能比較迅速找到賬戶,實現(xiàn)這 樣的幾個功能,就要通過鏈表來存儲數(shù)據(jù)結(jié)構(gòu),其結(jié)構(gòu)則按照C語言的相關(guān)知識 定義結(jié)構(gòu)體,其中儲戶開戶、銷戶就是實現(xiàn)鏈表的插入與刪除,而存入、支出等 活動則是實現(xiàn)鏈表中結(jié)點的查找,然后進行更改。2概要設(shè)計1) 、數(shù)據(jù)結(jié)構(gòu):typedef struct message c

5、har n ame10; char sex3; int old; char no20; double base; double ir; int code; int year; int yday; message *n ext;message,*Message;2) 、各種函數(shù)說明:Message out()將txt文件中的信息讀出 tm * date();調(diào)用系統(tǒng)時間void make();對文件中已有賬戶進行處理 void it(Message );將信息寫入txt文件 void create()創(chuàng)建新賬戶void debit(Message);從賬戶中取款 void credit(Mess

6、age);向賬戶中存款 in t chaxu n();查詢賬戶信息void rework(Message);修改賬戶密碼 int ma in();主函數(shù)3詳細設(shè)計1)、頭文件headerfile.h中,聲明結(jié)構(gòu)體和函數(shù):typedef struct message char n ame10; char sex3; int old;char no20; double base; double ir; int code; int year; int yday; message *n ext;message,*Message; Message out();tm * date(); void make

7、();void it(Message ); void create();void debit(Message); 圖1程序結(jié)構(gòu)圖圖1程序結(jié)構(gòu)圖void credit(Message); int chax un();void rework(Message);2)int main()/主函數(shù)int choice=0;while(1) cout«"請選擇操作:1、創(chuàng)建賬戶2、查詢賬戶0、退出n"cin> >choice;switch(choice)case 1:create();break;case 2:chax un() ;break;case 0:ret

8、ur n 0;default:cout<<"你敲錯鍵了。n"break; tm * date()調(diào)用系統(tǒng)時間time_t rawtime;struct tm * timei nfo;time ( & rawtime );timei nfo = localtime ( & rawtime );return time info;void make()預(yù)處理賬目Message p,q,head=out();p=head->n ext;while(p!=NULL)for(i nt i=1;i<二d->tm_yday-p->yday

9、+365*(d->tm_year-p->year);i+) 一 一 p->base=p->base+p->base*p->ir;p=p->n ext;q=head->n ext;ofstream fout("Message.txt");fout.close();while(q!=NULL)it(q);q=q-> next;Message out()/將 txt文件中的信息讀出Message p,q,head;head=new message;p=head;ifstream fin ("Message.txt&q

10、uot;);if(!fin) cout«"文件打開失敗 n"return head;elsewhile(!fi n.eof()q=new message;fin>>q->n ame»q->sex>>q->old>> q->no>> q->base>>q->ir>>q->code>>q->yea r»q->yda;q-> next=NULL;p->n ext=q;p=p->n ext;fin

11、.close();retur n head;void it(Message q)/將信息寫入txt文件ofstream fout("Message.txt",ios:app);if(!fout) cout«"文件打開失敗 n" fout«e ndl<< q->n ame<<" "<<q->sex<<""<<q->old<<""<< q->no<<"

12、"vvq->base<v" "<<q->ir<<" "<vq->code<v" "<<d->tm_yearvv" "<<d->tm_yday; fout.close();void create。/創(chuàng)建賬戶Message q=new message; cout«"*請輸入客戶的信息*"<<endl; cout«"姓名:";cin»q

13、->name;coutvv"性另廿:"cin>> q->sex;cout«"年齡:"cin»q->old;coutvv"身份證號:"cin>>q->no;cout«"本金:"cin>> q->base;coutvv"禾 率:"cin>> q->ir;coutvv"密碼:"cin>> q->code; q->year=d->tm_yea

14、r;q->yday=d->tm_yday; q->n ext=NULL;it(q);士void debit(Message p)/取款double mon ey,m;coutvv"請輸入取款金額:"cin>>mon ey;m=p->base-m on ey;if(mv0.00)coutvv"余額不足!n"else coutvv"取款成功!n"vv"當前余額為:"vvm;p->base=m;coutvvendl; 丄void credit(Message p)/存款doubl

15、e mon ey,m;coutvv"請輸入存款金額:"ci n>>mo ney;m=p->base+m on ey;coutvv"存款成功!n"vv"當前余額為:"vvm;p->base=m;coutvvendl;void rework(Message p)/修改密碼int code1,code2;coutvv"請輸入新密碼:"cin> >code1;coutvv"請再次輸入新密碼:"c in >>code2; if(code1=code2)cou

16、tvv"修改密碼成功! n"p->code=code1; else coutvv'兩次輸入的新密碼不一致!修改密碼失??!n"in t chaxu n()查詢賬戶make();Message head=new message;head=out();Message p,q;p=head->n ext; char a20;i nt b,choice;coutvv"請輸入要查詢的賬戶的身份證號:"c in> >a;cout«"請輸入密碼:"c in> >b;while(p!=NU

17、LL)if(strcmp(a,p->n o)=0&&b=p->code)coutvv"*要查詢的賬戶信息為*"<<endl;coutvv"姓名"vvsetw(6)<<"性別"<<setw(5)<<"年齡 "<<setw(15)vv"身份證號"<<setw(13)vv"余額"<<setw(10)vv"利率 n"coutvvp->n amevv

18、setw(5)vvp->sexvvsetw(5)vvp->old<vsetw(20)vvp->no <<set w(9)vvp->basev<setw(10)vvp->irvve ndl;break;else p=p->n ext;if(p=NULL)cout<<"賬戶或密碼錯誤!n"return 0; while(1)coutvv"請選擇操作:1、存款 2、取款 3、修改密碼0、回主菜單n "c in> >choice;switch(choice)case 1:cred

19、it(p);break;case 2:debit(p);break;case 3:rework(p);break;case 0:retur n 0;default:coutvv"你敲錯鍵了。n"break;q=head->n ext;ofstream fout("Message.txt");fout.close(); while(q!=NULL)it(q);q=q->n ext;4調(diào)試分析程序調(diào)試采用Dev C+實現(xiàn),程序在調(diào)試過程中遇到了各種問題,首先在開 戶程序是時我是主函調(diào)試錯誤,在原理上是可行,但調(diào)試時總得不到正確結(jié)果, 后來改為基本

20、類型整型后就很好的得到了滿意結(jié)果,其它一些小錯誤在不斷地調(diào) 試,不斷地改善后,基本達到可滿意的效果5數(shù)據(jù)結(jié)構(gòu)課程設(shè)計5用戶使用圖3取款6數(shù)據(jù)結(jié)構(gòu)課程設(shè)計圖3取款#數(shù)據(jù)結(jié)構(gòu)課程設(shè)計-T舌期儲蓄帳目管理系統(tǒng)十1,2,按步驟開戶完成一系列操作戶 肖 Ail詢詢息杳査信 戶名口戶 瑩賬用 戶照矍si習(xí)岀札7,8,圖3取款#數(shù)據(jù)結(jié)構(gòu)課程設(shè)計圖2主界面6測試結(jié)果圖3取款#數(shù)據(jù)結(jié)構(gòu)課程設(shè)計圖3取款#數(shù)據(jù)結(jié)構(gòu)課程設(shè)計i Eildd.exeX"用戶取款業(yè)務(wù)dx=1製號工辦A入取圖3取款#數(shù)據(jù)結(jié)構(gòu)課程設(shè)計7數(shù)據(jù)結(jié)構(gòu)課程設(shè)計N0.1NO. 2NO.3NO. 4NO.5NO. 612365478998745

21、6.00三浩1236547899874561&&Q&.0012365478998745610000.00辜浩1236547899874561&&Q&.001112365478998745610000.00李浩1236547899874561000B.00圖4用戶資料圖5余額查詢#數(shù)據(jù)結(jié)構(gòu)課程設(shè)計8數(shù)據(jù)結(jié)構(gòu)課程設(shè)計口 X務(wù)c子符數(shù)<20>=李浩份證號碼:123654789987456:10000“添加用戶云姓身聲 戶戶金成 用用戶戶 入入開用 iAto 請請輸添#數(shù)據(jù)結(jié)構(gòu)課程設(shè)計圖6用戶添加7結(jié)論體會第一次做課程設(shè)計,開始自己讀題時,思

22、路不是很清晰,首先定義了一個結(jié) 構(gòu)體,包含了儲戶的各類信息,如姓名,賬號,金額等等,并利用文件將用戶信 息加以存儲。開戶時將輸入的信息寫入文件,存款和取款時對用戶的存款加以處 理并更新到文件中。在分析好活期儲蓄帳目管理的功能模塊后,開始編寫代碼, 通過這次對銀行管理系統(tǒng)的編寫與調(diào)試, 鞏固了有關(guān)結(jié)構(gòu)體的知識及其操作,鍛 煉了實際應(yīng)用能力。8參考文獻1 馮博琴.軟件技術(shù)基礎(chǔ)(修改版)西安交通大學(xué)出版社,1997.2 嚴蔚敏.數(shù)據(jù)結(jié)構(gòu).清華大學(xué)出版社,2003.3 李蕓芳.軟件技術(shù)基礎(chǔ)(第二版).清華大學(xué)出版社,2000.4 徐孝凱.數(shù)據(jù)結(jié)構(gòu)(C語言描述).清華大學(xué)出版社,2004.9源程序#i

23、nclude<stdio.h> #i nclude<stri ng.h>#in cludevc oni o.h>#i nclude<stdlib.h>#defi ne file "temp.txt"/數(shù)據(jù)存儲的文件名姓名,身份證號,以生成自動賬struct user用戶類型定義(賬號,余額)int id;char n ame20;char pers on_nu m19;double mon ey;void add()添加用戶資料printf("%30sn","* 添加用戶 *");printf

24、("nn");struct user getuser();int count();/函數(shù)目的:計算文件中的記錄數(shù)目號FILE *fp;int nu mber;struct user temp;if(fp=fope n(file,"ab")=NULL)printf("cannot open file!n"); exit(1);temp=getuser();讀取用戶名nu mber=co un t();temp.id=nu mbe葉1;/生成自動賬號fwrite(&temp,sizeof(struct user),1,fp);pr

25、intf("添加用戶成功!n");fclose(fp);in t cou nt()函數(shù)目的:計算文件中的記錄總數(shù)FILE *fp;int num;struct user temp;num=0;if(fp=fope n(file,"rb")=NULL)printf("cannot open file!n”); exit(1);while(fread(&temp,sizeof(struct user),1,fp)nu m+;fclose(fp);return num;struct user getuser()void get name(ch

26、ar *n ame);void getpers on_nu m(char *pers on_nu m);struct user temp;printf("請輸入用戶姓名(字符數(shù)<20):");讀取相關(guān)開戶信息get name(temp .n ame);printf("請輸入用戶身份證號碼:");getpers on_nu m(temp.pers on_nu m);printf("輸入開戶金額:");do/判斷開戶金額(>=100)scan f("%lf", &temp.m on ey);fflu

27、sh(stdi n);if(temp.mo ney)<100.0)printf("開戶金額不能小于100n");elsebreak;printf("重新輸入開戶金額:");while(1);return temp;void getname(char *name)/函數(shù)功能:讀取用戶姓名(字符數(shù)<20)do scan f("%s", name);fflush(stdi n);if(strle n(n ame)=0) printf("姓名不能為空!n");elseif(strle n(n ame)>=

28、20) printf("姓名不能超過20個字符!n"); else break;printf("重新輸入姓名:");while(1);/循環(huán)以保證讀入數(shù)據(jù)有效 void getperson_num(char*person_num)/ 函數(shù)功能:讀取用戶身份證號碼 (15位或者18位)doint i,mark;char ch;for(i=0,mark=0;i+)/輸入有效性判斷(只能是數(shù)字)if(ch=getchar()!='n')if(ch<=9&&ch>='0')pers on_nu mi=c

29、h;elseprintf("身份證號碼只能是數(shù)字!n");mark=1;break;elsebreak;pers on_nu mi='0'if(mark=1)con ti nue;if(strle n(pers on_nu m)!=15&&strle n(pers on_nu m)!=18) printf("身份證號碼只能是15位,或者18位!n");elsebreak;printf("重新輸入身份證號碼:");while(1);循環(huán)以保證讀入數(shù)據(jù)有效void select_name()/按照姓名查詢賬

30、戶余額void get name(char *n ame);printf("%30sn","*按照姓名查詢賬戶余額*");printf("%8s %15s %15s %10sn","賬號","用戶姓名","身份證號碼","存款余額 ");printf("nn");FILE * fp;struct user temp;char n ame20;if(fp=fope n(file,"rb")=NULL)printf(&q

31、uot;cannot open file!n");exit(1);printf("輸入要查詢的姓名:");/調(diào)用讀取用戶名函數(shù)get name( name);while(fread(&temp,sizeof(struct user),1,fp)/ 循環(huán)讀取每一條記錄判斷是否為要查看的記錄if(strcmp(temp .n ame ,n ame)=0)printf("NO.%d %15s %15s %.2fn",temp.id,,temp.person_num,temp. mon ey);fclose(fp);void

32、select_id()按照賬號查詢賬戶余額int coun t();printf("%30sn","*按照編號查詢賬戶余額*");printf("%8s %15s %15s %10sn","編號","用戶姓名","身份證號碼","存款余額 ");printf("nn");FILE * fp; struct user temp; int i,max num;if(fp=fope n(file,"rb")=NULL)pr

33、intf("cannot open file!n”); exit(1);maxnum=co un t();printf("輸入要查詢賬號:");判斷賬號是否在記錄中sca nf("%d",&i);if(i<1|i>max num)printf("你要查詢的賬號不存在!");return;while(fread(&temp,sizeof(struct user),1,fp)循環(huán)讀取每一條記錄判斷是否為要查看的記錄if(temp.id=i)printf("NO.%d %15s %15s %.

34、2fn",temp.id,,temp.person_num,temp. mon ey);fclose(fp);void display()/顯示用戶資料printf("%30sn","* 用戶資料顯示 *");printf("%8s %15s %15s %10sn","賬號","用戶姓名","身份證號碼","存款余額 ");printf("nn");FILE * fp;struct user temp;if(

35、fp=fope n(file,"rb")=NULL)printf("cannot open file!n"); exit(1);while(fread(&temp,sizeof(struct user),1,fp)printf("NO.%d %15s %15s %.2fn",temp.id,,temp.person_num,temp. mon ey);fclose(fp);void save_mo ney() /函數(shù)功能:按賬號存款printf("%30sn","* 用戶存款業(yè)務(wù)

36、 *");printf("nn");int coun t();FILE *fp;int i,num ,mark;struct user *temp;num=cou nt();根據(jù)記錄數(shù)申請空間temp=(struct user *)malloc(num*sizeof(struct user);if(fp=fope n(file,"rb")=NULL)printf("cannot open file!n");exit(1);for(i=0;i< num;i+)/將文件內(nèi)容存入數(shù)組fread(&tempi,size

37、of(struct user),1,fp);fclose(fp);printf("輸入要存款賬號:");/讀取存款賬號sca nf("%d",&mark);if(mark<1|mark >num)printf("你要存款賬號不存在!");return;if(fp=fope n(file,"wb")=NULL)/寫方式打開文件,覆蓋原文件中的內(nèi)容printf("cannot open file!n");exit(1);for(i=0;i <nu m;i+)if(tempi

38、.id=mark)double mon ey=0;printf("輸入要存入的金額:"); sea nf("%lf",&mon ey);if(mon ey<=0)printf("只能為正數(shù)!n");mon ey=0;tempi.m oney +=mon ey;/修改該用戶的信息 fwrite(&tempi,sizeof(struct user),1,fp);fclose(fp);free(temp);printf("你存款業(yè)務(wù)已辦妥!n");void get_mo ney()函數(shù)功能:用戶取款

39、printf("%30sn","* 用戶取款業(yè)務(wù) *"); printf("nn");int coun t();FILE *fp;int i,num ,mark;struct user *temp;num=cou nt();/根據(jù)記錄數(shù)申請空間temp=(struct user *)malloc(num*sizeof(struct user);if(fp=fope n(file,"rb")=NULL)printf("cannot open file!n"); exit(1);for(i=0;i&

40、lt; nu m;i+)讀取文件內(nèi)容fread(&tempi,sizeof(struct user),1,fp);fclose(fp);printf("輸入要取款賬號:"); sca nf("%d",&mark); if(mark<1|mark >num)printf("你要取款賬號不存在門; return;if(fp=fope n(file,"wb")=NULL)printf("cannot open file!n”); exit(1);for(i=0;i< num;i+)/寫方

41、式打開文件,覆蓋原文件中的內(nèi)容if(tempi.id=mark)double mon ey=0;printf("輸入要取出的金額:");sea nf("%lf",&mon ey);if(mo ney<=0)判斷用戶余額是否足夠printf("只能為正數(shù)!n");mon ey=0;elseif(mon ey>tempi.m on ey)printf("你的余額不足!n");mon ey=0;tempi.m oney -=mon ey;fwrite(&tempi,sizeof(struct

42、user),1,fp);fclose(fp);free(temp);printf("你取款業(yè)務(wù)已辦妥!n");void del()銷戶int eoun t();printf("%30sn","* 注銷賬戶 *");printf("%8s %15s %15s %10sn","賬號","用戶姓名","身份證號碼","存款余額 ");printf("nn");FILE * fp; struct user temp; int

43、 i,max num;if(fp=fope n(file,"rb")=NULL) printf("cannot open file!n"); exit(1);maxnum=co un t();printf("輸入要銷戶賬號:");判斷編號是否在記錄中sca nf("%d",&i);if(i<1|i>max num)printf("你要查詢的賬號不存在!");return;while(fread(&temp,sizeof(struct user),1,fp)循環(huán)讀取每一條記錄判斷是否為要查看的記錄if(temp.id=i&&temp.money=0.00) 余額為 0 temp.id=-1

溫馨提示

  • 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)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論