銀行賬戶管理程序_第1頁
銀行賬戶管理程序_第2頁
銀行賬戶管理程序_第3頁
銀行賬戶管理程序_第4頁
銀行賬戶管理程序_第5頁
已閱讀5頁,還剩5頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡(jiǎn)介

1、/*銀行賬戶管理問題描述設(shè)計(jì)一個(gè)銀行賬戶管理程序,賬戶的信息有賬號(hào)(唯一) 、姓名、余額、身份證號(hào)碼、單位、 電話號(hào)碼、地址等,允許用戶進(jìn)行如下操作:開戶、銷戶、存款、取款、轉(zhuǎn)賬、查詢,一個(gè)用戶可以有 多個(gè)戶頭, 賬戶的數(shù)值沒有上限。 */#include #include #include using namespace std;class consumer;class YH / 銀行類public:void set_account();/ void del_account(); / void transfer(int); / void enter_account(); /銀行開戶功能注銷賬

2、戶功能轉(zhuǎn)賬功能進(jìn)入用戶個(gè)人信息功能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(int id,string Name,string PassWord,float m)ID=id;name=Na

3、me;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); void dec_money(float); float get_money();/卡轉(zhuǎn)帳private:int ID; / 開戶帳號(hào)

4、string passwd; / string name; /用float money; /開用戶密碼用戶姓名 開戶金額;void YH:save()ofstream ofile(bankdat.dat,ios:out); ofstream outfile(bankdat.dat,ios:out); int n=0;outfileacnum ; for(n=0;nacnum;n+) outfileID ; outfilemoney ; outfilename ; outfilepasswd ; outfile.close();/* 讀入用戶信息功能實(shí)現(xiàn) */void YH:load()ifst

5、ream infile(bankdat.dat,ios:in); if(!infile)cerr 讀取錯(cuò)誤 , 無資料中 !acnum;for(n=0;nid; infilem;infilenam; infilepassw;accountn-passwd;consumer * acc = new consumer(id,nam,passw,m); accountn = acc;infile.close();cout 讀取資料正常 !endl;/* 轉(zhuǎn)賬功能實(shí)現(xiàn) */void YH:transfer(int x)int id;coutid;int flag = 1;int i = 0; whil

6、e(iget_id() flag = 0; else i+; if(flag)cout 帳號(hào)不存在 !endlendl; return ;float b;coutendlb;while(b=0)cout 請(qǐng)輸入正確的數(shù)字 !endl;COUtb;if(aCCOuntx-get_mOney()b) COut對(duì)不起 , 金額不夠 !deC_mOney(b);aCCOunti-add_mOney(b); return;/* 賬戶金額計(jì)算 */vOid COnsumer:add_mOney(flOat x) mOney=x+mOney;vOid COnsumer:deC_mOney(flOat x)m

7、Oney=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();/* 主界面顯示 */void YH:functionshow()int n;dosystem(cls); load(); coutendl 請(qǐng)輸入相應(yīng)的操作序號(hào)進(jìn)行操作 :endl;cout endl;COut e ndl;COut 1.開戶 endl;COut endl;COut 2.賬

8、戶登錄 endl;COut endl;COut 3.賬戶注銷 endl;COut endl;COut 4.退出系統(tǒng) endl;COut endl;cout endl;COUtn;while(n4)COut操作錯(cuò)誤,請(qǐng)輸入正確的操作序號(hào)!endl;COutn;switCh(n)Case 1: set_aCCOunt();/開戶break;Case 2:enter_aCCOunt();/登錄break;case 3: del_account();/ 注銷 break;case 4: exitYH();/ 退出 break;cin.get();while(true);void YH:enter_ac

9、count()int id;coutid;int flag = 1;int i = 0;/_page_break_while(iget_id() flag = 0; else i+;if(flag)cout 帳號(hào)不存在 !endlendl;return;coutpassw;if(passw!=accounti-get_passwd() return; accounti-display();cin.get();cin.get();int n;dosystem(cls);cout 請(qǐng)選擇下列操作: endl;cout endl;cout endl;cout 1.查看賬戶信息 endl;cout e

10、ndl;cout 2.取款 endl;cout endl;cout 3.存款 endl;cout endl;cout 4.修改密碼 endl;cout endl;cout 5.轉(zhuǎn)賬 endl;endl;endl; endl;endl;cout cout 6. 返回上一菜單 cout cout COUtn;switCh(n)Case 1: aCCOunti-display();break;Case 2: aCCOunti-fetChmOney();save();break;Case 3:aCCOunti-savemOney();save();break;Case 4:aCCOunti-Chang

11、e_passwd();save();break;Case 5:transfer(i);save();break;Case 6:return;Cin.get();Cin.get();while(1);vOid YH:set_aCCOunt()int id;string nam;string passw;flOat m;COutendlid;COutendlnam;COutendlpassw;COutendlm; while(m=0)請(qǐng)輸入開戶號(hào): ; 請(qǐng)輸入開戶人姓名: 請(qǐng)輸入開戶密碼: 請(qǐng)輸入存入金額 :COut 請(qǐng)輸入正確的數(shù)字 !m;COnsumer * aCC = new COnsume

12、r(id,nam,passw,m); aCCOuntaCnum = aCC;COut 開戶成功 !endlendl;acnum+; save(); cin.get();return;void YH:del_account()int id;coutendlid;int flag = 1;int i = 0; while(iget_id()flag = 0;elsei+;if(flag)cout 該帳號(hào)不存在,請(qǐng)重新輸入 !endl; return;for(int j=i;jacnum;j+)accountj = accountj+1; accountacnum-1=NULL; acnum-;co

13、ut 你的賬號(hào)已注銷 !endlendl; save();cin.get();return;void consumer:change_passwd()string pwd,repwd;coutpwd;coutrepwd;if(pwd!=repwd)cout 你輸入的兩次密碼不一樣 , 按輸入鍵返回上一層菜單 !endl; elsecout 密碼修改成功,請(qǐng)牢記 !endl;cin.get();void consumer:fetchmoney()float m;char ch;docoutendl輸入取款金額:m;while(m=0)cout 請(qǐng)輸入正確的數(shù)字 !endl;coutm;if(mo

14、neym)cout 對(duì)不起,你的余額不足 !endl;elsemoney=money-m;coutendl 操作成功,請(qǐng)收好錢 !endl;cout 是否要繼續(xù)該項(xiàng)操作: (Y/N) endl;coutch;while(ch!=n&ch!=N&ch!=Y&ch!=y)/選擇錯(cuò)誤時(shí)判定COUtch;while(Ch=y|Ch=Y);vOid COnsumer:savemOney()/ 存錢函數(shù)功能實(shí)現(xiàn)flOat C;Char Ch;dOcoutendl請(qǐng)輸入要存入的金額:C;while(c=0)cout 輸入錯(cuò)誤 , 請(qǐng)重新輸入 !endl;coutc;money=money+c;cout 操作已成功 !endl;cout 是否要繼續(xù)該項(xiàng)操作: (Y/N) endl;coutch;while(ch!=n&ch!=N&ch!=Y&ch!=y)coutch; while(ch=y|ch=Y);int YH:acnum=0;void consumer:display()/ 用戶信息界面 system(cls);c

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(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ì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論