![完整版銀行賬戶管理程序文檔良心出品_第1頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-1/18/a323a042-c3a2-49e1-b116-aaa223ea9f94/a323a042-c3a2-49e1-b116-aaa223ea9f941.gif)
![完整版銀行賬戶管理程序文檔良心出品_第2頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-1/18/a323a042-c3a2-49e1-b116-aaa223ea9f94/a323a042-c3a2-49e1-b116-aaa223ea9f942.gif)
![完整版銀行賬戶管理程序文檔良心出品_第3頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-1/18/a323a042-c3a2-49e1-b116-aaa223ea9f94/a323a042-c3a2-49e1-b116-aaa223ea9f943.gif)
![完整版銀行賬戶管理程序文檔良心出品_第4頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-1/18/a323a042-c3a2-49e1-b116-aaa223ea9f94/a323a042-c3a2-49e1-b116-aaa223ea9f944.gif)
![完整版銀行賬戶管理程序文檔良心出品_第5頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-1/18/a323a042-c3a2-49e1-b116-aaa223ea9f94/a323a042-c3a2-49e1-b116-aaa223ea9f945.gif)
下載本文檔
版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、1.1要求程序運(yùn)行時(shí),可以由用戶選擇進(jìn)行何種操作,用戶銷(xiāo)戶后賬號(hào)被回收,并且該賬 號(hào)可以繼續(xù)分配給其它賬戶,不允許用戶透支.開(kāi)戶操作要求輸入用戶信息后自動(dòng)獲 取賬號(hào).根據(jù)姓名或賬號(hào)可以進(jìn)行用戶的信息查詢, 所有的賬戶信息應(yīng)存放到一個(gè)文 件中,可以隨時(shí)的訪問(wèn)和更新.1.2任務(wù)設(shè)計(jì)一個(gè)銀行賬戶治理程序,賬戶的信息有賬號(hào)唯一、姓名、余額、身份證 號(hào)、單位、 號(hào)、地址等,允許用戶進(jìn)行如下操作:開(kāi)戶、銷(xiāo)戶、存款、取款、 轉(zhuǎn)賬、查詢,一個(gè)用戶可以有多個(gè)戶頭,賬戶的數(shù)值沒(méi)有上限.2分析和設(shè)計(jì)2.1系統(tǒng)分析及設(shè)計(jì)思路2.1.1類(lèi)與對(duì)象類(lèi)是一種復(fù)雜的數(shù)據(jù)類(lèi)型,它是將不同類(lèi)型的數(shù)據(jù)和與這些數(shù)據(jù)相關(guān)的操作封裝 在一
2、起的集合體.類(lèi)的一般形式為:class類(lèi)名protect:保護(hù)的數(shù)據(jù)和成員函數(shù) public:公用的數(shù)據(jù)和成員函數(shù)private:私有的數(shù)據(jù)和成員函數(shù) ;對(duì)象是運(yùn)行期的根本實(shí)體,它是一個(gè)封裝了數(shù)據(jù)和操作這些數(shù)據(jù)的代碼的邏輯實(shí) 體.對(duì)象的一般格式為:類(lèi)名 對(duì)象名表;2.1.2成員函數(shù)的實(shí)現(xiàn)成員函數(shù)的實(shí)現(xiàn),可以放在類(lèi)體內(nèi),也可以放在類(lèi)體外,但必須在類(lèi)體內(nèi)給出原 型說(shuō)明.放在類(lèi)體內(nèi)定義的函數(shù)被默認(rèn)為內(nèi)聯(lián)函數(shù), 而放在類(lèi)體外定義的函數(shù)是一般 函數(shù),如果要定義為內(nèi)聯(lián)函數(shù)那么需要在前面加上關(guān)鍵字 inline.與普通函數(shù)不同的是,成員函數(shù)是屆于某個(gè)類(lèi)的,在類(lèi)體外定義成員函數(shù)的一半 形式為:返回類(lèi)型 類(lèi)名
3、:成員函數(shù) 參數(shù)說(shuō)明函數(shù)體2.1.3本程序涉及的類(lèi)一usersclass users根據(jù)類(lèi)的定義:類(lèi)是一種復(fù)雜的數(shù)據(jù)類(lèi)型,它是將不同類(lèi)型的數(shù)據(jù)和與這些數(shù)據(jù) 相關(guān)的操作封裝在一起的集合體.本設(shè)計(jì)的賬戶信息姓名、余額、身份證號(hào)、單 位、 號(hào)、地址等恰好可以定義成一個(gè)類(lèi)一 users,偽代碼如下:賬戶類(lèi)private :char id5;賬號(hào)char name9;char id_card19;char company40;char company_phone12;char moble_phone12;char address31;long balance;users *next;public :us
4、ers(ifstream &file_in);char password11;密碼賬戶名身份證號(hào)單位單位 地址余額指向下一個(gè)賬戶構(gòu)造函數(shù),同時(shí)從文件讀取賬戶數(shù)據(jù)void new_user();新建賬戶信息void put_id(int id_new);獲取賬號(hào)char *get_id();返回賬號(hào)耿款void saving();存款void saving(long money);轉(zhuǎn)入帳long virement();轉(zhuǎn)出賬;2.1.4 main函數(shù)的實(shí)現(xiàn)一個(gè)程序中main是最簡(jiǎn)單但是最重要的函數(shù),他負(fù)責(zé)著整個(gè)程序的調(diào)用運(yùn)行, 我們?cè)O(shè)計(jì)的這個(gè)main函數(shù)思路很簡(jiǎn)單,但是實(shí)現(xiàn)起來(lái)稍微復(fù)雜一
5、些,本想簡(jiǎn)化一下, 可是始終沒(méi)有解決,本程序 main函數(shù)基于一個(gè)switch ()語(yǔ)句來(lái)實(shí)現(xiàn)各個(gè)操作的選 擇,在case后面再調(diào)用具體操作函數(shù)來(lái)實(shí)現(xiàn)操作,由于要選擇的操作比較多,所以 才顯得復(fù)雜些,具體偽代碼如下:int main()int choice;do zi_title();cin>>choice;bool blag=0;switch(choice)case 1 :cout<<-開(kāi)戶-n;user = new users;user->put_id(n_id(head);user->new_user();case 2 : cout<<&q
6、uot;-銷(xiāo)戶-n"if(head=0)( cout<<"還沒(méi)有賬戶!建議開(kāi)戶!"<<endl; break; case 3 :cout<<"存寂 n"user = u_search(head,2,0);case 4 :cout<<"-取款-n"user=u_search(head,2,0);user->take_money();break;case 5 :cout<<"-轉(zhuǎn)賬-n"case 6 :cout<<"-查詢
7、-n"cout<<"選擇查詢條件:n 1-賬戶名2-賬號(hào)3-身份證號(hào)選項(xiàng):"case 0 :f_out.open("banksystem.txt");if(f_out.fail()(cout<<"文件翻開(kāi)錯(cuò)誤!"<<endl;exit(1);default :cout<<"沒(méi)有該選項(xiàng)! "<<endl;break;while(choice);cout<<"謝謝使用! "<<endl;return 0;2
8、.2主要類(lèi)圖users-id5-password11-password11-name9-company40-company_phone12-moble_phone12-address31-balance+new_user()+put_id()+get_balance()+take_money()+saving()+saving()+virement()圖3.1 users類(lèi)圖2.3函數(shù)流程圖開(kāi)戶new_user函數(shù)流程圖如下charnew_pw11,ok_.blag=0;*i!='0'*i<='!'|*i>=''for(char *i
9、=new_pwblag=1;break;i+strcmp(new.blagcout<<"確認(rèn)密碼:"blag=1;blag=0;strcpy(password,new_pw);圖3.2開(kāi)戶new_user流程圖存款users:saving函數(shù)流程圖如下:圖3.3存款users:saving流程圖轉(zhuǎn)賬users:virement函數(shù)流程圖如下:圖3.4轉(zhuǎn)賬users:virement流程圖3具體代碼實(shí)現(xiàn)#include <iostream>#include <fstream>/輸入/輸出文件流#include <iomanip>
10、/O流限制頭文件,就像C里面的格式化輸出一樣#include <cctype>#include <cstring>#include <cmath>#include <cstdlib>/ 各函數(shù)集合using namespace std;活空該行,輸入abcde回車(chē)symbol由a變成被b覆蓋,又被c覆蓋知道最后symbol只存了一個(gè)'n'void new_line()char symbol;docin.get(symbol);/輸入字符,cin 吃回車(chē)while(symbol != 'n');數(shù)字轉(zhuǎn)換到字符申voi
11、d int2str(int n, char *str)char buf10=""int i = 0;int len = 0;int temp = n < 0 ? -n: n; / temp 為 n 的絕對(duì)值if (str = NULL)return;while(temp)bufi+ = (temp % 10) + '0' /把 temp 的每一位上的數(shù)存入 buf temp = temp / 10;len = n < 0 ? +i: i; 如果n是負(fù)數(shù),那么多需要一位來(lái)存儲(chǔ)負(fù)號(hào)stri = 0;末尾是結(jié)束符023while(1)i-;if(buf
12、len-i-1 = 0)break;stri = buflen-i-1; 把buf數(shù)組里的字符拷到字符申如果是負(fù)數(shù),添加一個(gè)負(fù)號(hào)if (i = 0 ) ( stri='-' /該用于治理開(kāi)啟程序的賬戶和密碼void safe_conduct()( int input_num=0;char un11,pw11;cout<<"請(qǐng)先登陸:(用戶名為:9021315密碼為:0000) "<<endl;bool blag;標(biāo)志錯(cuò)誤doblag=0;cout<<"用戶名:"cin>>un;cout<
13、;<"密碼:"cin>>pw;if(strcmp(un,"9021315")!=0)blag=1;cout<<"用戶名輸入錯(cuò)誤! "<<endl;if(!blag)if(strcmp(pw,"0000)!=0)blag=1;cout<<"用戶密碼輸入錯(cuò)誤! "<<endl;if(blag)input_num+;switch(input_num)case 1: cout<<'您還可以輸入兩次!"<<e
14、ndl; break;case 2: cout<<'您還可以輸入一次!"<<endl; break;case 3: cout<<'您沒(méi)有權(quán)限繼續(xù)輸入,程序?qū)⒁P(guān)閉!"<<endl; exit(0);while(blag);/直到正確才跳出用于治理賬戶信息class users賬戶類(lèi)private :賬號(hào)密碼賬戶名身份證號(hào)單位單位 地址余額指向下一個(gè)賬戶char id5;char password11;char name9;char id_card19;char company40;char company_ph
15、one12;char moble_phone12;char address31;long balance;users *next;public :構(gòu)造函數(shù),同時(shí)從文件讀取賬戶數(shù)據(jù)重載構(gòu)造函數(shù),使之用于開(kāi)戶新建賬戶信息獲取賬號(hào)users(ifstream &file_in);users() balance=0; next=NULL;void new_user();void put_id(int id_new);char *get_id(); 返回賬號(hào)char *get_password();返回賬戶名/返回身份證號(hào)返回 號(hào)返回余額取款存款轉(zhuǎn)入帳轉(zhuǎn)出賬寫(xiě)入文件輸出到屏幕char *get_
16、name();char *get_id_card();char *get_mob_ph();long get_balance();void take_money();void saving();void saving(long money);long virement();void out_to_file(ofstream &file_out);void out_to_screen();得到指針?lè)祷刂羔榲oid put_next(users *n);users *back_next();users:users(ifstream &file_in)file_in>>i
17、d>>name>>id_card>>company>>company_phone>>moble_phone>>addres s>>balance;next = NULL;void users:new_user() char new_pw11,ok_new_pw11;cout<<"請(qǐng)您輸入賬戶名:"cin>>name;bool blag;doblag=0; cout<<"請(qǐng)您輸入密碼:"cin>>new_pw;for(char
18、 *i=new_pw;*i!='0'i+)/ 檢查密碼是否合法(if(*i<='!'|*i>='')( blag=1;cout<<"密碼不符合標(biāo)準(zhǔn)! !請(qǐng)重新輸入! ! "<<endl;break;cout<<"確認(rèn)密碼:"cin>>ok_new_pw;if(strcmp(new_pw,ok_new_pw)!=0)(blag=1;cout<<"密碼不同!"<<endl;else blag=0;while(
19、blag);strcpy(password,new_pw);cout<<"請(qǐng)輸入您身份證號(hào):"cin>>id_card;cout<<"請(qǐng)輸入您的單位:"cin>>company;cout<<"情輸入您的單位 :"cin>>company_phone;cout<<"請(qǐng)輸入您的 號(hào):"cin>>moble_phone;cout<<"請(qǐng)輸入您的地址:"cin>>address;cou
20、t<<endl;cout<<"您申請(qǐng)的賬戶信息為:賬號(hào):"<<id<<"賬戶名:"<<name<<" 身份證號(hào):"<<id_card<<" 單位:"<<company<<" 單位 :"<<company_phone<<" 號(hào):"<<moble_phone<<" 地址:"<<add
21、ress <<" 賬戶余額:"<<balance<<endl<<endl<<endl;void users:put_id(int id_new)(一 一char new_id5;int num;for(int i=3;i>=0;i-)數(shù)字轉(zhuǎn)換成字符申( num = id_new % 10;new_idi = num + '0'id_new /= 10;new_id4 = '0' strcpy(id,new_id);char *users:get_id()return id;ch
22、ar *users:get_password()return password; char *users:get_name() return name ; char *users:get_id_card()return id_card; char *users:get_mob_ph()return moble_phone;long users:get_balance()return balance;void users:take_money()if(balance<=0) cout<<您的余額已經(jīng)為空!無(wú)法取款!n存款后可以再??!"<<endl;retu
23、rn ;long m;/輸入取款金額bool blag;doblag=0;cout<<請(qǐng)輸入取款金額:"cin>>m;if(m>=balance) blag=1;cout<<"您輸入的金額大于余額,無(wú)法取出! !請(qǐng)重新輸入! ! "<<endl;while(blag);balance = balance - m;void users:saving()long m;bool blag;do blag=0;cout<<請(qǐng)輸入存款金額:"cin>>m;if(m<0)cout&l
24、t;<請(qǐng)正確輸入金額!"blag=1;while(blag);balance = balance + m;void users:saving(long money)(balance = balance + money;long users:virement()( long money;bool blag;do(blag=0;cout<<"請(qǐng)輸入要轉(zhuǎn)賬的金額 cin>>money;if(money>=balance)(cout<<"余額缺乏!請(qǐng)重新輸入! "<<endl;blag=1; while
25、(blag);balance = balance - money;return money; void users:out_to_file(ofstream &file_out)(file_out<<'n'<<id<<""<<name<<""<<id_card<<" "<<company<<"<<company_phone<<" "<<mo
26、ble_phone<<" "<<address<<" "<<balance; void users:out_to_screen()(cout.setf(ios:left);/ 數(shù)值從左讀起cout<<setw(6)<<"賬號(hào):"<<id/set(6)表示設(shè)置6個(gè)空格來(lái)輸出數(shù)據(jù)<<setw(8)<<"<<setw(10)<<"<<setw(13)<<"&
27、lt;<setw(12)<<"<<setw(12)<<"<<setw(13)<<" <<setw (9) <<" <<endl;用戶名:"<<name身份證號(hào):"<<id_card公司:"<<company公司 :"<<company_phone 號(hào):"<<moble_phone 地址:"<<address余額:"
28、<<balancecout.setf(ios:right);void users:put_next(users *n)( next = n; users *users:back_next()(return next; 查詢:選擇查詢條件:1-賬戶名;2-賬號(hào);3-身份證號(hào);users *u_search(users *head,int choice,bool b=1)(users *p;bool blag=1;switch(choice)(case 0 :break;case 1 :char name9;cout<<"輸入賬戶名:"cin>&g
29、t;name;for(p=head;p!=NULL;p=p->back_next()if(strcmp(p->get_name(),name)=0)p->out_to_screen();blag=0;break;case 2 :char id5;cout<<"輸入賬號(hào):"cin>>id;for(p=head;p!=NULL;p=p->back_next()if(strcmp(p->get_id(),id)=0)if(b) p->out_to_screen();blag=0;elsereturn p;break;ca
30、se 3 :char id_card19;cout<<"輸入身份證號(hào):"cin>>id_card;for(p=head;p!=NULL;p=p->back_next() if(strcmp(p->get_id_card(),id_card)=0)p->out_to_screen();blag=0;break;default :cout<<"選項(xiàng)錯(cuò)誤! "<<endl; return NULL;if(blag)( cout<<"沒(méi)有該賬戶!"<<e
31、ndl; return NULL; int n_id(users *head)( int id;int now_id=0,num;users *p;char ne_id5;bool blag;for(id=0;id<=9999;id+)(blag=1;now_id = id;int2str(now_id,ne_id);數(shù)字轉(zhuǎn)換成字符申for(int i=3;i>=0;i-)數(shù)字轉(zhuǎn)換成字符申( num = now_id % 10; ne_idi = num + '0' now_id /= 10;ne_id4 = '0'遍歷,找到鏈表中不存在的賬號(hào)for
32、(p=head;p!=NULL;p=p->back_next() _if(strcmp(p->get_id(),ne_id)=0) blag = 0; break; if(blag) return id;void zi_title()cout<<""<<endl< <endl;cout<<" 1-開(kāi)戶2-銷(xiāo)戶3-存款 4-取款5-轉(zhuǎn)賬6-查詢0-退出 <<endl<<endl; cout<<""<<endl;void title()(co
33、ut<<"歡迎使用銀行賬戶治理程序"<<endl;cout<<""<<e ndl;int main()( ifstream f_in;ofstream f_out;f_in.open("banksystem.txt");safe_conduct();users *p;users *head,整個(gè)鏈表的頭結(jié)點(diǎn)指針*user,新建賬戶指針*later,整個(gè)鏈表的尾結(jié)點(diǎn)指針*next;下一個(gè)結(jié)點(diǎn)if(f_in.peek()!=EOF)( head = new users(f_in);user
34、= later = head;for(;f_in.peek()!=EOF;)(next = new users(f_in);user->put_next(next);later = next; elsehead=NULL;f_in.close();int choice;do( zi_title();cin>>choice;bool blag=0;switch(choice)(case 1 :cout<<"-開(kāi)戶-n"user = new users;user->put_id(n_id(head);user->new_user();i
35、f(head=NULL)head = user;elselater->put_next(user);later = user;break;case 2 :cout<<"-銷(xiāo)戶-n"if(head=0) cout<<"還沒(méi)有賬戶!建議開(kāi)戶! "<<endl; break; char id_5;cout<<"請(qǐng)輸入要銷(xiāo)戶的賬號(hào):;cin>>id_; 刪除鏈表中的結(jié)點(diǎn)next = head;if(strcmp(head->get_id(),id_)=0)head = head-&
36、gt;back_next();delete next;blag=1;elsefor(user=head;user!=NULL;user=user->back_next()if(strcmp(user->get_id(),id_)=0) next->put_next(user->back_next();blag=1;delete user;break;next=user;if(blag)cout<<"刪除成功! "<<endl;elsecout<<"沒(méi)有該賬戶! "<<endl;bre
37、ak;case 3 :cout<<"寂n"user = u_search(head,2,0);user->saving();break;case 4 :cout<<"-取款-n"user=u_search(head,2,0); user->take_money();break;case 5 :cout<<"-轉(zhuǎn)賬-n"cout<<"轉(zhuǎn)出:n<<*;user = u_search(head,2,0);cout<<"W入:n"<<*;next = u_search(head,2,0);next->
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝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ù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 星球版地理七年級(jí)下冊(cè)《第二節(jié) 俄羅斯》聽(tīng)課評(píng)課記錄3
- 湖北職業(yè)技術(shù)學(xué)院《期貨交易模擬操作》2023-2024學(xué)年第二學(xué)期期末試卷
- 豪裝房屋出租合同范本
- 河北工業(yè)大學(xué)《大學(xué)生創(chuàng)業(yè)概論》2023-2024學(xué)年第二學(xué)期期末試卷
- 許昌職業(yè)技術(shù)學(xué)院《社區(qū)思想政治教育》2023-2024學(xué)年第二學(xué)期期末試卷
- 西藏大學(xué)《國(guó)際私法》2023-2024學(xué)年第二學(xué)期期末試卷
- 塔城職業(yè)技術(shù)學(xué)院《測(cè)試技術(shù)基礎(chǔ)》2023-2024學(xué)年第二學(xué)期期末試卷
- 金陵科技學(xué)院《學(xué)前兒童常見(jiàn)問(wèn)題行為與矯正》2023-2024學(xué)年第二學(xué)期期末試卷
- 師徒結(jié)對(duì)聽(tīng)評(píng)課活動(dòng)記錄
- 河南對(duì)外經(jīng)濟(jì)貿(mào)易職業(yè)學(xué)院《經(jīng)濟(jì)法》2023-2024學(xué)年第二學(xué)期期末試卷
- 復(fù)旦中華傳統(tǒng)體育課程講義05木蘭拳基本技術(shù)
- GB/T 13234-2018用能單位節(jié)能量計(jì)算方法
- (課件)肝性腦病
- 北師大版五年級(jí)上冊(cè)數(shù)學(xué)教學(xué)課件第5課時(shí) 人民幣兌換
- 工程回訪記錄單
- 住房公積金投訴申請(qǐng)書(shū)
- 高考物理二輪專(zhuān)題課件:“配速法”解決擺線問(wèn)題
- 檢驗(yàn)科生物安全風(fēng)險(xiǎn)評(píng)估報(bào)告
- 京頤得移動(dòng)門(mén)診產(chǎn)品輸液
- 如何做一名合格的帶教老師PPT精選文檔
- ISO9001-14001-2015內(nèi)部審核檢查表
評(píng)論
0/150
提交評(píng)論