C++銀行賬戶管理課程設計報告_第1頁
C++銀行賬戶管理課程設計報告_第2頁
C++銀行賬戶管理課程設計報告_第3頁
C++銀行賬戶管理課程設計報告_第4頁
C++銀行賬戶管理課程設計報告_第5頁
已閱讀5頁,還剩13頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、jingchu university of technologyc+艮行賬戶管理課程設計報告學院:計算機工程學院 班 級:09級計算機科學與技術1班學生姓名: 學 號:2009404010125設計地點(單位):a5-101設 計題 目:銀行賬戶管理程序完成日期:2011年12月25日指導教師評語:成績(五級記分制):教 師 簽名:一、設計思想 03二、模塊設計與分析 03三、程序設計介紹 04四、框架結構圖 04五、程序代碼 05六、測試數(shù)據(jù) 14七、數(shù)據(jù)調試 14八、課程設計總結 16九、課程設計教材及主要參考資料 1618一、設計思想定義一個用戶類customer和一個銀行類yh,程序運

2、行時,可以由用戶選擇進行開戶、登錄、取款、存款、修改密碼、轉賬、銷戶操作,用戶銷戶后賬號被回收, 并且該賬號可以繼續(xù)分配給其它賬戶, 不允許用戶透支, 根據(jù)姓名或賬號可以進行用戶的信息查詢, 所有的賬戶信息應存放到一個文件中, 可以隨時的訪問和更新。二、模塊設計與分析1 登錄頁面:輸入帳號和密碼,根據(jù)用戶輸入的帳號和密碼,到后臺文件查詢, 若正確則登錄成功, 并保存卡好信息已備后用。 若帳號存在和密碼不匹配或無該帳號已經(jīng)注銷,提示該帳號已存在或已注銷。2 主界面頁面:主要導航欄有存款、取款、賬戶信息、注銷、注銷、返回上一步。3 開戶頁面: 提供開戶界面, 由用戶輸入新賬戶的信息, 將該信息保存

3、到文件中,并將開戶金額作為該卡的第一次存款記錄存人文件。4 存錢頁面:從登錄界面得到帳號,并提供數(shù)據(jù)輸入界面,等待用戶的輸入存款金額,同時將存錢的金額顯示在頁面上。5 取款頁面:從登錄界面得到帳號,并提供數(shù)據(jù)輸入界面,等待用戶輸入取款金額, 如果取款金額大于該用戶卡上的余額則不能取款, 或者將新的余額寫人文件,并將本次取款事件寫入文件同時將取錢的金額顯示在頁面上。6 賬戶信息頁面:從登錄界面得到帳號,把本人顯示到界面中。7 轉賬頁面:從登錄界面得到帳號,輸入要轉入的帳號,在輸入金額,顯示在頁面上,如果金額超過余額將操作失敗。8 注銷頁面:從關閉文件,狀態(tài)為注銷,最后關閉整個系統(tǒng)。三、程序設計介

4、紹系統(tǒng)由2個類構成,yh (銀行類)和consumer (客戶類),consumer(客 戶類)是yh (銀行類)的公有繼承類。yh (銀行類)中有實現(xiàn)登陸系統(tǒng),開戶, 銷戶,轉賬,退出系統(tǒng)等功能函數(shù),consumer (客戶類)中有實現(xiàn)存錢,取錢, 修改個人賬號密碼,顯示個人賬號信息等功能函數(shù)。因為consumer(客戶類)是yh (銀行類)的公有繼承類,所以,一個用戶只需創(chuàng)建一個consumer (客戶類)對象,當用戶進行開戶,銷戶等操作時,可以直接調用yh (銀行類)的成員函數(shù)。銀行類中的函數(shù):void set_account(); /銀行開戶功能void del_account();

5、注銷賬戶功能void transfer(int); 轉賬功能void enter_account(); /砒入用戶個人信息功能void addmoney(int,float);/存款功能void exityh();/ 退出系統(tǒng)v修 改 密 碼v. 查 看 信 息五、程序代碼#include<iostream> #include <string>#include<fstream> using namespace std;class consumer;/銀行類class yhpublic:void set_account();/ 銀行開戶功能void del_a

6、ccount();/注銷賬戶功能void transfer(int); /轉賬功能void enter_account(); / 進入用戶個人信息功能void addmoney(int,float);/ 存款功能void exityh();/ 退出系統(tǒng)void functionshow();void save();void load();/ 功能界面protected:consumer *account20;static int acnum;/ 賬戶數(shù);class consumer:public yh/ 用戶類,繼承銀行類的屬性public:friend class yh;consumer(i

7、nt id,string name,string password,float m)id=id;name=name;money=m;passwd=password;consumer()id=0;name='0'money=0;passwd='0'int get_id()return id;void savemoney();/ 取錢string get_passwd()return passwd;/ 取得密碼 void display();void fetchmoney();/取錢void change_passwd();void add_money(float)

8、;void dec_money(float);float get_money();/ 卡卡轉帳private:int id; / 開戶帳號string passwd; / 用戶密碼string name; / 用戶姓名float money;/開戶金額;void yh:save()ofstream ofile("bankdat.dat",ios:out);ofstream outfile("bankdat.dat",ios:out);int n=0;outfile<<acnum<<" "for(n=0;n<

9、;acnum;n+)outfile<<accountn->id<<" "outfile<<accountn->money<<""outfile<<accountn->name<<" "outfile<<accountn->passwd<<""outfile.close();/* 讀入用戶信息功能實現(xiàn)*/void yh:load()ifstream infile("bankdat.dat&

10、quot;,ios:in);if(!infile)cerr<<" 讀取錯誤 ,無資料中 !"<<endl;return;int n=0;int id,m;string nam,passw;infile>>acnum;for(n=0;n<acnum;n+)infile>>id;infile>>m;infile>>nam;infile>>passw;accountn->passwd;consumer * acc = new consumer(id,nam,passw,m);accou

11、ntn = acc;infile.close();cout<<" 讀取資料正常!"<<endl;/* 轉賬功能實現(xiàn)*/void yh:transfer(int x)int id;cout<<" 請輸入帳號:"cin>>id;int flag = 1;int i = 0;while(i<acnum)&&(flag)if(id=accounti->get_id() flag = 0; else i+;if(flag)cout<<" 帳號不存在!"<

12、;<endl<<endl;return ;float b;cout<<endl<<" 請輸入你要轉帳的金額 :"cin>>b;while(b<=0)cout<<" 請輸入正確的數(shù)字!"<<endl;cout<<"<"cin>>b;if(accountx->get_money()<b) cout<<" 對不起 ,金額不夠 !"<<endl; else accountx-

13、>dec_money(b);accounti->add_money(b);return;/* 賬戶金額計算*/void consumer:add_money(float x)money=x+money;void consumer:dec_money(float x)money=money-x;void yh:addmoney(int x,float y)accountx->money=accountx->money-y;float consumer:get_money()return money;void main()yh yh;yh.functionshow();)/

14、*主界面顯示*/void yh:functionshow()(int n;dosystem("cls"); load();cout«endl<<"請輸入相應的操作序號進行操作:"«endl;"«endl; "«endl; "«endl; "«endl; "«endl; "«endl; "«endl; "«endl; "«endl; "&

15、#171;endl;"«endl;cout«"cout«" cout«" 1.開戶cout«" cout«" 2.賬戶登錄cout«" cout«" 3.賬戶注銷cout«" cout«" 4.退出系統(tǒng)cout«" cout«"cout«"cin»n;while(n<1|n>4)(cout<<"

16、操作錯誤,請輸入正確的操作序號!"«endl;cout«"cin»n;)switch(n)(case 1: set_account();開戶 break;case 2:enter_account();登錄 break;case 3: del_account();注銷 break;case 4: exityh();/ 退出 break;)cin.getq;while(true);)void yh:enter_account()int id;cout<<"請輸入帳號:"cin»id;int flag = 1

17、;int i = 0;/_page_break_while(i<acnum)&&(flag)(if(id=accounti->get_id() flag = 0; else i+;)if(flag)(cout«"帳號不存在!"«endl«endl;return;)cout<<"請輸入密碼:"string passw;cin»passw;if(passw!=accounti->get_passwd() return;accounti->display();cin.g

18、et();cin.get();int n;dosystem("cls");cout«"請選擇下列操作:"<<endl;cout<<" "«endl;cout«" "«endl;cout«" 1 .查看賬戶信息 "«endl;cout«" "«endl;cout«" 2.取款 "«endl;cout«" "

19、«endl;cout«" 3.存款 "«endl;cout«" "«endl;cout«" 4.修改密碼 "«endl;cout«" "«endl;cout«" 5.轉賬 "«endl;cout«" "«endl;cout«" 6.返回上一菜單 "«endl;cout«" "&#

20、171;endl;cout«" cout«"cin»n;"«endl;switch(n)case 1: accounti->display();break;case 2: accounti->fetchmoney();save();break;case 3:accounti->savemoney();save();break;case 4:accounti->change_passwd();save();break;case 5:transfer(i);save();break;case 6:retu

21、rn;cin.get();cin.get();while(1);void yh:set_account()int id;string nam;string passw;float m;cout<<endl<<" 請輸入開戶號: "cin>>id;cout<<endl<<" 請輸入開戶人姓名: "cin>>nam;cout<<endl<<" 請輸入開戶密碼: "cin>>passw;cout<<endl<<

22、" 請輸入存入金額 :"cin>>m;while(m<=0)cout<<" 請輸入正確的數(shù)字!"<<endl;cin>>m;consumer * acc = new consumer(id,nam,passw,m);accountacnum = acc;cout<<" 開戶成功 !"<<endl<<endl;acnum+;save();cin.get();return;void yh:del_account()int id;cout<<

23、;endl<<" 請輸入你要注銷的帳戶號 :"cin>>id;int flag = 1;int i = 0;while(i<acnum)&&(flag)if(id = accounti->get_id()flag = 0;elsei+;if(flag)cout<<" 該帳號不存在,請重新輸入 !"<<endl;return;for(int j=i;j<acnum;j+)accountj = accountj+1;accountacnum-1=null;acnum-;cout

24、<<" 你的賬號已注銷 !"<<endl<<endl;save();cin.get();return;void consumer:change_passwd()string pwd,repwd;cout<<" 請輸入新密碼: "cin>>pwd;cout<<" 請再輸入一次新密碼: "cin>>repwd;if(pwd!=repwd)!"<<endl;cout<<" 你輸入的兩次密碼不一樣,按輸入鍵返回上一層

25、菜單elsecout<<" 密碼修改成功,請牢記!"<<endl;cin.get();void consumer: :fetchmoney()(float m;char ch;do(cout«endl«"輸入取款金額¥ >"«endl;cin»m;while(m<=0)(cout<<"請輸入正確的數(shù)字!"«endl;cout«"cin»m;)if(money<m)(cout<<&q

26、uot;對不起,你的余額不足!"«endl;)elsemoney=money-m;cout«endl<<"操作成功,請收好錢 !"«endl;)cout«"是否要繼續(xù)該項操作:(y/n)"«endl;cout«"cin»ch;while(ch!='n'&&ch!='n'&&ch!='y'&&ch!='y')/選擇錯誤時判定(cout«

27、"cin»ch;)while(ch='y'|ch='y');)void consumer: :savemoney()/ 存錢函數(shù)功能實現(xiàn)(float c;char ch;docout<<endl<<"請輸入要存入的金額 :"<<"¥ >"<<endl ;cin>>c;while(c<=0)(cout<<"輸入錯誤,請重新輸入!"<<endl;cout<<"&

28、lt;"cin>>c;)money=money+c;cout<<"操作已成功!"<<endl;cout<<"是否要繼續(xù)該項操作:(y/n) "<<endl;cout<<"<"cin>>ch;while(ch!='n'&&ch!='n'&&ch!='y'&&ch!=y)(cout<<" f "cin>>

29、;ch;)while(ch='y'|ch='y');)int yh二acnum=0;void consumer:display() 用戶信息界面system("cls");cout<<"#"<<endl;cout<<"#"<<endl;cout<<"#用戶姓名:"<<name<<endl;cout<<"#"<<endl;cout<<"#帳號:"<<id<<endl;cout<<"#"<<endl;cout<<"#余額:"<<money<<endl;cout<<"#"<<endl;cout<<"#按輸入鍵回到上一菜單"<<endl;cout<<"#"<<

溫馨提示

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

評論

0/150

提交評論