C++銀行自動取款機源程序代碼_第1頁
C++銀行自動取款機源程序代碼_第2頁
已閱讀5頁,還剩8頁未讀 繼續免費閱讀

下載本文檔

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

文檔簡介

1、c+銀行自動取款機源程序代碼 模擬銀行自動取款機系統 /consumer.h #include iostream #include string using namespace std; class consumer public: void initconsumer(string ,string ,string ,float);/初始化 string getname(); string getid(); string getpassword(); float getmoney(); void setname(string n); void setid(string i); void setp

2、assword(string pw); void setmoney(float m); void changpassword();/更改密碼 void showme();/顯示賬戶信息 void fetchmoney();/取款 private: string password;/用戶密碼 string name;/用戶姓名 string id;/用戶卡號 float money;/用戶余額 ; /bank.h #include iostream #include string #includeconsumer.h using namespace std; class bank public:

3、 void welcome();/歡迎界面 void exitsystem();/退出系統 void menu();/選擇菜單 int seek(string);/查找卡號 void initconsumer(int i,string n,string i,string pw,float m); string getname(); string getid(); 模擬銀行自動取款機系統 string getpassword(); float getmoney(); /void setname(string n); /void setid(string i); /void setpassword

4、(string pw); /void setmoney(float m); void changpassword();/更改密碼 void showme();/顯示賬戶信息 void fetchmoney();/取款 private: int i; consumer cs50; ; /consumer.cpp #include consumer.h void consumer:initconsumer(string n,string i,string pw,float m) name=n; id=i; password=pw; money=m; string consumer:getname(

5、) return name; string consumer:getid() return id; string consumer:getpassword() return password; float consumer:getmoney() return money; 模擬銀行自動取款機系統 void consumer:changpassword()/更改密碼 cout*歡迎進入更改密碼界面*endl; string p; cout請輸入原密碼; cinp; string q,w; if(p=password) cout請輸入您的新密碼:; cinq; cout請再次輸入您的新密碼:; c

6、inw; coutwendl; if(w=q) password=q; cout密碼修改勝利endl; else cout您兩次輸入的密碼不全都,修改失敗!endl; else cout您輸入的密碼錯誤!endl; void consumer:fetchmoney() /取款 float a; cout 請輸入取款金額:endl; cina; while(a = 0) cout輸入金額有誤,請您重新輸入正確的金額:endl; cina; if(money-a0) cout 對不起,你的余額不足! endl; else cout 正在取款中,請稍候.endl; money= money- a;

7、cout 交易勝利!endl; 模擬銀行自動取款機系統 void consumer:showme() /顯示賬戶信息 cout*endl; cout當前賬號信息:endl; cout用戶姓名:name endl; cout銀行卡號: id endl; cout卡內余額: moneyendl; cout*endl; /bank.cpp #include bank.h void bank:welcome() /歡迎界面 cout*歡迎使用哆啦a夢自動取款機*endl; cout請輸入卡號:endl; string id; int flag=-1; cinid; flag=seek(id); voi

8、d bank:exitsystem() /退出系統 cout*感謝您的使用*endl; cout*請取卡,收好您的銀行卡*endl; exit(0); void bank:menu()/選擇菜單 int n; do cout*endl; cout請輸入相應的操作序號endl; cout1 修改密碼endl; cout2 取款endl; 模擬銀行自動取款機系統 cout3 顯示余額endl; cout4 退出系統endl; cout*endl; cinn; while(n1|n4) cout操作錯誤,請輸入正確的操作序號!endl; cinn; switch(n) case 1: changpa

9、ssword(); break; case 2: fetchmoney(); break; case 3: showme(); break; case 4: exitsystem(); break; while(true); int bank:seek(string id) for(int j=0;j50;j+) if(id=csj.getid() i=j; break; if(j=50) i=-1; return i; 模擬銀行自動取款機系統 void bank:initconsumer(int i,string n,string i,string pw,float m)/初始化 csi.i

10、nitconsumer(n,i,pw,m); string bank:getname() return csi.getname(); string bank:getid() return csi.getid(); string bank:getpassword() return csi.getpassword(); float bank:getmoney() return csi.getmoney(); void bank:changpassword()/更改密碼 csi.changpassword(); void bank:showme()/顯示賬戶信息 csi.showme(); void bank:fetchmoney()/取款 csi.fetchmoney(); /main.cpp #include iostream #include string #include bank.h 模擬銀行自動取款機系統 using namespace std; int main() bank b; b.initconsumer(

溫馨提示

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

評論

0/150

提交評論