C++银行管理系统方案.docx

上传人:b****8 文档编号:11287803 上传时间:2023-02-26 格式:DOCX 页数:19 大小:576.57KB
下载 相关 举报
C++银行管理系统方案.docx_第1页
第1页 / 共19页
C++银行管理系统方案.docx_第2页
第2页 / 共19页
C++银行管理系统方案.docx_第3页
第3页 / 共19页
C++银行管理系统方案.docx_第4页
第4页 / 共19页
C++银行管理系统方案.docx_第5页
第5页 / 共19页
点击查看更多>>
下载资源
资源描述

C++银行管理系统方案.docx

《C++银行管理系统方案.docx》由会员分享,可在线阅读,更多相关《C++银行管理系统方案.docx(19页珍藏版)》请在冰豆网上搜索。

C++银行管理系统方案.docx

C++银行管理系统方案

基于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.h"

usingnamespacestd;

classBank_Management

{

private:

stringnew_name;

stringpre_name;

intpassword;

doubleextra_money;

public:

voidcreat_user(stringname,intpass);

intsign_user(stringname,intpass);

doubleaccount_balance();

voidwithdraw_money();

voidquery_account();

voidchange_password();

};

Bank_Managementoperation[1024];

ofstreamRec_history("Historicalrecords.txt",ios:

:

in|ios:

:

out|ios:

:

app);

intmain_ui()

{

printf("\n\n");

printf("\t\t%cWelcometouseBankManagementSystem!

%c\n",3,3);

printf("\t\t\t%cCopyrightbySunYu_peng!

%c\n",4,4);

printf("\t\t\t%c++++++++++++++++%c\n",4,4);

printf("\t\t\t+Hereisthesystemmenu!

+\n");

printf("\t\t\t%c++++++++++++++++%c\n",4,4);

printf("\t\t\t++\n");

printf("\t\t\t+1.Depositmoney+\n");

printf("\t\t\t++\n");

printf("\t\t\t+2.Withdrawmoney+\n");

printf("\t\t\t++\n");

printf("\t\t\t+3.Querybalance+\n");

printf("\t\t\t++\n");

printf("\t\t\t+4.Historicalrecords+\n");

printf("\t\t\t++\n");

printf("\t\t\t+5.Changepassword+\n");

printf("\t\t\t++\n");

printf("\t\t\t+6.Saveandexit+\n");

printf("\t\t\t++\n");

printf("\t\t\t%c++++++++++++++++%c\n",4,4);

printf("\t\tPleaseentertheorderthatyouwant:

");

intorder;

cin>>order;

if(order==1)

{

system("cls");

operation[0].account_balance();

}

elseif(order==2)

{

system("cls");

operation[0].withdraw_money();

}

elseif(order==3)

{

operation[0].query_account();

}

elseif(order==4)

{

system("cls");

printf("\n\n\n\n");

Secondary_ui();

printf("\tAlldateshavebeensavedinthefile(Historicalrecords.txt)");

Sleep(5000);

system("cls");

}

elseif(order==5)

{

operation[0].change_password();

}

elseif(order==6)

{

Rec_history<<"Theuserdecidedtoexitthesystem!

\n";

system("cls");

return0;

}

else

{

Rec_history<<"Theuserhasdoneawrongoperation!

Thesystemexited!

\n";

system("cls");

return0;

}

}

voidBank_Management:

:

creat_user(stringname,intpass)

{

new_name=name;

password=pass;

}

intBank_Management:

:

sign_user(stringname,intpass)

{

ifstreamOpenFile("Usernameandpassword.txt");

stringget_name;

intget_pass;

stacksign;

stringstreamn;

stringpass_str;

n<

n>>pass_str;

while(OpenFile>>get_name>>get_pass)

{

stringstreamtemp;

stringtemp_str;

temp<

temp>>temp_str;

stringall_str=get_name+''+temp_str;

sign.push(all_str);

}

while(sign.size()!

=0)

{

if(name+''+pass_str==sign.top())

{

pre_name=name;

Rec_history<<"Theuser:

"<

returntrue;

}

else

{

sign.pop();

}

}

OpenFile.close();

}

doubleBank_Management:

:

account_balance()

{

printf("\n\n");

Secondary_ui();

printf("\t\tPleaseenterthemoneythatyouwantotdeposit:

");

double_money;

cin>>_money;

ifstreamDeposit_money("Accountbalance.txt");

mapDeposit_Money;

map:

:

iteratorit;

stringtemp;

while(Deposit_money>>temp>>extra_money)

{

if(temp==pre_name)

{

extra_money=extra_money+_money;

Rec_history<<"Theuser:

"<

}

Deposit_Money.insert(pair(temp,extra_money));

}

Deposit_money.close();

ofstreamDepositMoney("Accountbalance.txt");

for(it=Deposit_Money.begin();it!

=Deposit_Money.end();it++)

{

DepositMoney<first<<"\t"<second<<"\n";

}

DepositMoney.close();

Sleep(1000);

system("cls");

return0;

}

voidBank_Management:

:

withdraw_money()

{

printf("\n\n");

Secondary_ui();

printf("\t\tPleaseenterthemoneythatyouwanttowithdraw:

");

double_money;

cin>>_money;

stringtemp;

ifstreamWithdraw_money("Accountbalance.txt");

mapWithdraw_Money;

map:

:

iteratorit;

while(Withdraw_money>>temp>>extra_money)

{

if(temp==pre_name)

{

extra_money=extra_money-_money;

Rec_history<<"User:

"<

}

Withdraw_Money.insert(pair(temp,extra_money));

}

Withdraw_money.close();

ofstreamWithdrawMoney("Accountbalance.txt");

for(it=Withdraw_Money.begin();it!

=Withdraw_Money.end();it++)

{

WithdrawMoney<first<<"\t"<second<<"\n";

}

WithdrawMoney.close();

Sleep(1000);

system("cls");

}

voidBank_Management:

:

query_account()

{

system("cls");

printf("\n\n\n\n");

Secondary_ui();

ifstreamRead_only("Accountbalance.txt");

stringtemp;

doubleextra;

cout<<"\t\t\t\t"<<"Name"<<"\t"<<"Account\n";

while(Read_only>>temp>>extra)

{

if(temp==pre_name)

{

cout<<"\t\t\t\t"<

}

}

Read_only.close();

Rec_history<<"Theuser:

"<

\n";

Sleep(5000);

system("cls");

}

voidBank_Management:

:

change_password()

{

ifstreamOpenFile("Usernameandpassword.txt");

stringtemp;

intpass;

mapchange_password;

map:

:

iteratorit;

system("cls");

printf("\n\n\n\n");

Secondary_ui();

printf("\t\tPleaseenterthenewpasswordyouwant:

");

doublenew_pass;

cin>>new_pass;

while(OpenFile>>temp>>pass)

{

if(temp==pre_name)

{

pass=new_pass;

}

change_password.insert(pair(temp,pass));

}

OpenFile.close();

ofstreamres_pass("Usernameandpassword.txt");

for(it=change_password.begin();it!

=change_password.end();it++)

{

res_pass<first<<"\t"<second<<"\n";

}

Rec_history<<"Theuser"<

\n";

Sleep(1000);

system("cls");

}

intmain()

{

stringname;

intpassword;

intcreat_num;

Rec_history<<"Softwarebegintoload!

\n";

while(true)

{

welcome_ui();

intorder;

cin>>order;

if(order==1)

{

printf("\t\tPleaseentertheprevioususer'sname:

\t");

cin>>name;

printf("\t\tPleaseenterprevioususer'spassword:

\t");

cin>>password;

if(operation[0].sign_user(name,password)==1)

{

system("cls");

main_ui();

}

else

{

printf("\tSorry,youhavedoneawrongoperation!

Pleaserestartthesystemagain!

\a\n");

Rec_history<<"Theuserwhosenameis"<

Sleep(1000);

system("cls");

}

}

elseif(order==2)

{

system("cls");

register_ui();

ofstreamCre_user;

Cre_user.open("Usernameandpassword.txt",ios:

:

in|ios:

:

out|ios:

:

app);

ofstreamIni_account;

Ini_account.open("Accountbalance.txt");

printf("\t\tPleaseentertheuser'squantityyouwant:

");

cin>>creat_num;

for(inti=0;i

{

printf("\t\tPleaseenterthenew%d-user'sname:

\t",i+1);

cin>>name;

printf("\t\tPleaseenterthe%d-user'spassword:

\t",i+1);

cin>>password;

Cre_user<

Ini_account<

Rec_history<<"Thesystemhascreatedauserwhosenameis"<

Rec_history<<"Thesystemhasinitialized"<

}

Cre_user.close();

Ini_account.close();

printf("\tWehavesavedalloperations!

Pleaserestartthesystemagain!

");

Sleep(1000);

system("cls");

}

elseif(order==3)

{

Rec_history<<"Theuserdecidedtoexitthesystem!

\n";

return0;

}

else

{

printf("\tSorry,youhavedoneawrongoperation!

Pleaserestartthesystemagain!

\a\n");

Rec_history<<"Theuserhasdoneawrongoperation!

Thesystemexited!

\n";

return0;

}

}

return0;

}

 

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 小学教育 > 学科竞赛

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1