C++银行管理系统.docx_第1页
C++银行管理系统.docx_第2页
C++银行管理系统.docx_第3页
C++银行管理系统.docx_第4页
C++银行管理系统.docx_第5页
已阅读5页,还剩8页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

基于C/C+实现银行管理系统声明:1. 本程序仅限个人交流和学习使用,切勿用于商业用途,一切源代码已经给出,可以根据自己的需要适当进行修改,但请保留原来的作者的版权信息。2. 程序里面难免有一些考虑不周到的地方,如果能够通过QQ或者邮箱告知,本人将万分感谢。 聊城大学 软件工程(和惠普合作培养软件开发)孙宇鹏2015年6月一 程序设计要求:设计并实现简单的银行存取款系统,系统主界面包括登录和注册两个选项,选择登录,提示用户输入银行帐号和密码,验证通过后进入主界面,主界面包括:存款、取款、查询余额、历史记录、修改密码等功能。注册功能让用户输入帐号和密码,在注册时要验证帐号是否已经存在。所有数据能够保存在文件中,退出系统后再次运行系统,之前注册的用户和存款信息都存在。二 程序实现的大致思路:1. 登陆界面和主界面的设计采用一行行printf输出。2. 登陆界面-主界面的切换采用system(“cls”)函数。3. 主界面的所有操作都涉及到了文件操作,所以采用3个文件分开储存和读取的方式。(1) 存取款以及查询余额:(2) 历史记录:(3) 账户密码信息:三、程序算法和数据结构:1.登陆用户:从文件里面读取信息,把用户名和密码分别压栈,读取结束,验证用户的名字和密码和栈顶元素是否匹配,不匹配栈顶元素出栈,直到栈的容量是空的时候。返回信息:用户或者密码错误。2.存款取款以及余额的查询:每次建立一个新的用户的时候,初始化此用户的所有信息。(主要是针对的余额)。从文件里面读取信息,采用二叉树的结构搜索用户。来实现查找。采用文件的重新写入来实现存取款。四、程序的一些设计的技巧以及注意情况:为了使程序模块化,我们要采用多文件的开发。也就是说,为了使程序简练,把一些需要重复利用的代码写到.h 的文件里面。五、代码实现:#include stdafx.h#include #include #include #include #include #include #include #include #include #include #include Welcome_UI.h#include Register_UI.h#include Sign_UI.h#include Secondary_UI.husing namespace std;class Bank_Managementprivate: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(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);printf(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(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(ttt%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)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_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;password = pass;int Bank_Management:sign_user(string name, int pass)ifstream OpenFile(User name and password.txt);string get_name;int get_pass;stack sign;stringstream n;string pass_str;n pass_str;while (OpenFile get_name get_pass)stringstream temp;string temp_str;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 has landed in the System . _money;ifstream Deposit_money(Account balance.txt);map Deposit_Money;map :iterator it;string temp;while (Deposit_money temp extra_money)if (temp = pre_name)extra_money = extra_money + _money;Rec_history The user : temp has deposited _money Yuann;Deposit_Money.insert(pair(temp, extra_money);Deposit_money.close();ofstream DepositMoney(Account balance.txt);for (it = Deposit_Money.begin(); it != Deposit_Money.end(); it+)DepositMoney first t second _money;string temp;ifstream Withdraw_money(Account balance.txt);map Withdraw_Money;map :iterator it;while (Withdraw_money temp extra_money)if (temp = pre_name)extra_money = extra_money - _money;Rec_history User : temp has withdrawed _money Yuann;Withdraw_Money.insert(pair(temp, extra_money);Withdraw_money.close();ofstream WithdrawMoney(Account balance.txt);for (it = Withdraw_Money.begin(); it != Withdraw_Money.end(); it+)WithdrawMoney first t second n;WithdrawMoney.close();Sleep(1000);system(cls);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 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;Sleep(5000);system(cls);void Bank_Management:change_password()ifstream OpenFile(User name and password.txt);string temp;int pass;map change_password;map :iterator it;system(cls);printf(nnnn);Secondary_ui();printf(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(temp, pass);OpenFile.close();ofstream res_pass(User name and password.txt);for (it = change_password.begin(); it != change_password.end(); it+)res_pass first t second n;Rec_history The user pre_name has changed his/her password!n;Sleep(1000);system(cls);int main()string name;int password;int creat_num;Rec_history order;if (order = 1)printf(tt Please enter the previous users name:t);cin name;printf(tt Please enter previous users 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 The user whose name is name creat_num;for (int i = 0; i name;printf(tt Plea

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论