C++銀行管理系統(tǒng)_第1頁
C++銀行管理系統(tǒng)_第2頁
C++銀行管理系統(tǒng)_第3頁
C++銀行管理系統(tǒng)_第4頁
C++銀行管理系統(tǒng)_第5頁
已閱讀5頁,還剩8頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡(jiǎn)介

1、基于C/C+實(shí)現(xiàn)銀行管理系統(tǒng)聲明:1. 本程序僅限個(gè)人交流和學(xué)習(xí)使用,切勿用于商業(yè)用途,一切源代碼已經(jīng)給出,可以根據(jù)自己的需要適當(dāng)進(jìn)行修改,但請(qǐng)保存原來的作者的版權(quán)信息。2. 程序里面難免有一些考慮不周到的地方,如果能夠通過QQ或者郵箱告知,本人將萬分感謝。 聊城大學(xué) 軟件工程和惠普合作培養(yǎng)軟件開發(fā)孫宇鵬2021年6月一 程序設(shè)計(jì)要求:設(shè)計(jì)并實(shí)現(xiàn)簡(jiǎn)單的銀行存取款系統(tǒng),系統(tǒng)主界面包括登錄和注冊(cè)兩個(gè)選項(xiàng),選擇登錄,提示用戶輸入銀行帳號(hào)和密碼,驗(yàn)證通過后進(jìn)入主界面,主界面包括:存款、取款、查詢余額、歷史記錄、修改密碼等功能。注冊(cè)功能讓用戶輸入帳號(hào)和密碼,在注冊(cè)時(shí)要驗(yàn)證帳號(hào)是否已經(jīng)存在。所有數(shù)據(jù)能夠保

2、存在文件中,退出系統(tǒng)后再次運(yùn)行系統(tǒng),之前注冊(cè)的用戶和存款信息都存在。二 程序?qū)崿F(xiàn)的大致思路:1. 登陸界面和主界面的設(shè)計(jì)采用一行行printf輸出。2. 登陸界面->主界面的切換采用system(“cls)函數(shù)。3. 主界面的所有操作都涉及到了文件操作,所以采用3個(gè)文件分開儲(chǔ)存和讀取的方式。(1) 存取款以及查詢余額:(2) 歷史記錄:(3) 賬戶密碼信息:三、程序算法和數(shù)據(jù)結(jié)構(gòu):1.登陸用戶:從文件里面讀取信息,把用戶名和密碼分別壓棧,讀取結(jié)束,驗(yàn)證用戶的名字和密碼和棧頂元素是否匹配,不匹配棧頂元素出棧,直到棧的容量是空的時(shí)候。返回信息:用戶或者密碼錯(cuò)誤。2.存款取款以及余額的查詢:每

3、次建立一個(gè)新的用戶的時(shí)候,初始化此用戶的所有信息。主要是針對(duì)的余額。從文件里面讀取信息,采用二叉樹的結(jié)構(gòu)搜索用戶。來實(shí)現(xiàn)查找。采用文件的重新寫入來實(shí)現(xiàn)存取款。四、程序的一些設(shè)計(jì)的技巧以及注意情況:為了使程序模塊化,我們要采用多文件的開發(fā)。也就是說,為了使程序簡(jiǎn)練,把一些需要重復(fù)利用的代碼寫到.h 的文件里面。五、代碼實(shí)現(xiàn):#include "stdafx.h"#include <iostream>#include <map>#include <stack>#include <sstream>#include <stdio

4、.h>#include <windows.h>#include <stdlib.h>#include <fstream>#include <vector>#include <algorithm>#include "Welcome_UI.h"#include "Register_UI.h"#include "Sign_UI.h"#include "Secondary_UI.h"using namespace std;class Bank_Managem

5、entprivate:string new_name;string pre_name;int password;double extra_money;public:void creat_user(string name, int pass);int sign_user(string name, int pass);double account_balance();void withdraw_money();void query_account();void change_password();Bank_Management operation1024;ofstream Rec_history(

6、"Historical records.txt", ios:in | ios:out | ios:app);int main_ui()printf("nn");printf("tt %cWelcome to use Bank Management System!%cn", 3, 3);printf("ttt %cCopyright by SunYu_peng!%cn", 4, 4);printf("ttt%c+ + + + + + + + + + + + + + + +%cn", 4, 4);p

7、rintf("ttt+ Here is the system menu! +n");printf("ttt%c+ + + + + + + + + + + + + + + +%cn", 4, 4);printf("ttt+ +n");printf("ttt+ 1.Deposit money +n");printf("ttt+ +n");printf("ttt+ 2.Withdraw money +n");printf("ttt+ +n");printf(&q

8、uot;ttt+ 3.Query balance +n");printf("ttt+ +n");printf("ttt+ 4.Historical records +n");printf("ttt+ +n");printf("ttt+ 5.Change password +n");printf("ttt+ +n");printf("ttt+ 6.Save and exit +n");printf("ttt+ +n");printf("t

9、tt%c+ + + + + + + + + + + + + + + +%cn", 4, 4);printf("tt Please enter the order that you want: ");int order;cin >> order;if (order = 1)system("cls");operation0.account_balance();else if (order = 2)system("cls");operation0.withdraw_money();else if (order = 3)

10、operation0.query_account();else if (order = 4)system("cls");printf("nnnn");Secondary_ui();printf("tAll dates have been saved in the file(Historical records.txt)");Sleep(5000);system("cls");else if (order = 5)operation0.change_password();else if (order = 6)Rec_

11、history << "The user decided to exit the system!n"system("cls");return 0;elseRec_history << "The user has done a wrong operation!The system exited!n"system("cls");return 0;void Bank_Management:creat_user(string name, int pass)new_name = name;passwo

12、rd = pass;int Bank_Management:sign_user(string name, int pass)ifstream OpenFile("User name and password.txt");string get_name;int get_pass;stack <string> sign;stringstream n;string pass_str;n << pass;n >> pass_str;while (OpenFile >> get_name >> get_pass)string

13、stream temp;string temp_str;temp << get_pass;temp >> temp_str;string all_str = get_name + ' ' + temp_str;sign.push(all_str);while (sign.size() != 0)if (name + ' ' + pass_str = sign.top()pre_name = name;Rec_history << "The user : " << name << &q

14、uot; " << "has landed in the System" << "."<<"n"return true;elsesign.pop();OpenFile.close();double Bank_Management:account_balance()printf("nn");Secondary_ui();printf("tt Please enter the money that you want ot deposit: ");doub

15、le _money;cin >> _money;ifstream Deposit_money("Account balance.txt");map <string, double> Deposit_Money;map <string, double> :iterator it;string temp;while (Deposit_money >> temp >> extra_money)if (temp = pre_name)extra_money = extra_money + _money;Rec_histor

16、y << "The user : " << temp << " " << "has deposited " << _money << " Yuann"Deposit_Money.insert(pair<string, double>(temp, extra_money);Deposit_money.close();ofstream DepositMoney("Account balance.txt");for (

17、it = Deposit_Money.begin(); it != Deposit_Money.end(); it+)DepositMoney << it->first << "t" << it->second << "n"DepositMoney.close();Sleep(1000);system("cls");return 0;void Bank_Management:withdraw_money()printf("nn");Secondary_ui

18、();printf("tt Please enter the money that you want to withdraw: ");double _money;cin >> _money;string temp;ifstream Withdraw_money("Account balance.txt");map <string, double> Withdraw_Money;map <string, double> :iterator it;while (Withdraw_money >> temp &g

19、t;> extra_money)if (temp = pre_name)extra_money = extra_money - _money;Rec_history << "User : " << temp << " " << "has withdrawed " << _money << " Yuann"Withdraw_Money.insert(pair<string, double>(temp, extra_money);

20、Withdraw_money.close();ofstream WithdrawMoney("Account balance.txt");for (it = Withdraw_Money.begin(); it != Withdraw_Money.end(); it+)WithdrawMoney << it->first << "t" << it->second << "n"WithdrawMoney.close();Sleep(1000);system("cls&

21、quot;);void Bank_Management:query_account()system("cls");printf("nnnn");Secondary_ui();ifstream Read_only("Account balance.txt");string temp;double extra;cout << "tttt" << "Name" << "t" << "Accountn"while (

22、Read_only >> temp >> extra)if (temp = pre_name)cout << "tttt" << temp << "t" << extra << endl;Read_only.close();Rec_history << "The user : " << temp << " " << "has Queried her/his accout!n&

23、quot;Sleep(5000);system("cls");void Bank_Management:change_password()ifstream OpenFile("User name and password.txt");string temp;int pass;map <string, int> change_password;map <string, int> :iterator it;system("cls");printf("nnnn");Secondary_ui();p

24、rintf("ttPlease enter the new password you want:");double new_pass;cin >> new_pass;while (OpenFile >> temp >> pass)if (temp = pre_name)pass = new_pass;change_password.insert(pair<string, int>(temp, pass);OpenFile.close();ofstream res_pass("User name and passwor

25、d.txt");for (it = change_password.begin(); it != change_password.end(); it+)res_pass << it->first << "t" << it->second << "n"Rec_history << "The user " << pre_name << " " << "has changed his/her p

26、assword!n"Sleep(1000);system("cls");int main()string name;int password;int creat_num;Rec_history << "Software begin to load!n"while (true)welcome_ui();int order;cin >> order;if (order = 1)printf("tt Please enter the previous user's name:t");cin >

27、> name;printf("tt Please enter previous user's password:t");cin >> password;if (operation0.sign_user(name, password) = 1)system("cls");main_ui( );elseprintf("tSorry,you have done a wrong operation!Please restart the system again! an");Rec_history << &

28、quot;The user whose name is " << name << " " << "has failed to enter the system.n"Sleep(1000);system("cls");else if (order = 2)system("cls");register_ui();ofstream Cre_user;Cre_user.open("User name and password.txt", ios:in | i

29、os:out | ios:app);ofstream Ini_account;Ini_account.open("Account balance.txt");printf("tt Please enter the user's quantity you want : ");cin >> creat_num;for (int i = 0; i<creat_num; i+)printf("tt Please enter the new %d-user's name:t", i + 1);cin >> name;printf("tt Plea

溫馨提示

  • 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)論