银行账户管理程序Word文件下载.docx
《银行账户管理程序Word文件下载.docx》由会员分享,可在线阅读,更多相关《银行账户管理程序Word文件下载.docx(15页珍藏版)》请在冰点文库上搜索。
![银行账户管理程序Word文件下载.docx](https://file1.bingdoc.com/fileroot1/2023-5/8/c848b0be-2f36-48b8-9931-85a724b11a43/c848b0be-2f36-48b8-9931-85a724b11a431.gif)
protected:
consumer*account[20];
staticintacnum;
//账户数
};
classconsumer:
publicYH//用户类,继承银行类的属性
friendclassYH;
consumer(intid,stringName,stringPassWord,floatm)
{
ID=id;
name=Name;
money=m;
passwd=PassWord;
}
consumer(){ID=0;
name='
0'
;
money=0;
passwd='
}
intget_id(){returnID;
voidsavemoney();
//取钱
stringget_passwd(){returnpasswd;
}//取得密码
voiddisplay();
voidfetchmoney();
//取钱
voidchange_passwd();
voidadd_money(float);
voiddec_money(float);
floatget_money();
//卡卡转帐
private:
intID;
//开户帐号
stringpasswd;
//用户密码
stringname;
//用户姓名
floatmoney;
//开户金额
voidYH:
:
save()
{ofstreamofile("
bankdat.dat"
ios:
out);
ofstreamoutfile("
intn=0;
outfile<
<
acnum<
"
"
for(n=0;
n<
acnum;
n++)
{outfile<
account[n]->
ID<
money<
name<
passwd<
outfile.close();
/*读入用户信息功能实现*/
load()
{ifstreaminfile("
in);
if(!
infile)
{cerr<
读取错误,无资料中!
endl;
return;
intid,m;
stringnam,passw;
infile>
>
{infile>
id;
m;
nam;
passw;
passwd;
consumer*acc=newconsumer(id,nam,passw,m);
account[n]=acc;
infile.close();
cout<
读取资料正常!
/*转账功能实现*/
transfer(intx)
{intid;
请输入帐号:
cin>
intflag=1;
inti=0;
while((i<
acnum)&
&
(flag))
{
if(id==account[i]->
get_id())flag=0;
elsei++;
}
if(flag)
帐号不存在!
endl<
return;
floatb;
cout<
请输入你要转帐的金额:
cin>
b;
while(b<
=0)
请输入正确的数字!
→"
if(account[x]->
get_money()<
b)cout<
对不起,金额不够!
!
else{account[x]->
dec_money(b);
account[i]->
add_money(b);
/*账户金额计算*/
voidconsumer:
add_money(floatx)
{money=x+money;
dec_money(floatx)
{money=money-x;
addmoney(intx,floaty)
{account[x]->
money=account[x]->
money-y;
floatconsumer:
get_money()
{returnmoney;
voidmain()
{YHyh;
yh.functionshow();
/*主界面显示*/
functionshow()
intn;
do
{system("
cls"
);
load();
请输入相应的操作序号进行操作:
㊣㊣㊣㊣㊣㊣㊣㊣㊣㊣㊣㊣㊣㊣㊣㊣㊣㊣㊣㊣㊣㊣㊣㊣㊣㊣㊣㊣㊣㊣"
㊣㊣"
㊣1.开户㊣"
㊣2.账户登录㊣"
㊣3.账户注销㊣"
㊣4.退出系统㊣"
n;
while(n<
1||n>
4)
{
操作错误,请输入正确的操作序号!
switch(n)
case1:
set_account();
//开户
break;
case2:
enter_account();
//登录
break;
case3:
del_account();
//注销
case4:
exitYH();
//退出
cin.get();
while(true);
enter_account()
//__page_break__
请输入密码:
stringpassw;
if(passw!
=account[i]->
get_passwd())return;
display();
cin.get();
intn;
do{system("
请选择下列操作:
◎☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆◎"
◎◎"
◎1.查看账户信息◎"
◎2.取款◎"
◎3.存款◎"
◎4.修改密码◎"
◎5.转账◎"
◎6.返回上一菜单◎"
switch(n)
{case1:
account[i]->
break;
case2:
fetchmoney();
save();
case3:
savemoney();
case4:
change_passwd();
case5:
transfer(i);
case6:
}cin.get();
while
(1);
set_account()
intid;
stringnam;
stringpassw;
floatm;
请输入开户号:
请输入开户人姓名:
请输入开户密码:
请输入存入金额:
while(m<
account[acnum]=acc;
开户成功!
acnum++;
del_account()
请输入你要注销的帐户号:
if(id==account[i]->
get_id())
flag=0;
else
i++;
该帐号不存在,请重新输入!
for(intj=i;
j<
j++)
account[j]=account[j+1];
account[acnum-1]=NULL;
acnum--;
你的账号已注销!
change_passwd()
stringpwd,repwd;
请输入新密码:
pwd;
请再输入一次新密码:
repwd;
if(pwd!
=repwd)
你输入的两次密码不一样,按输入键返回上一层菜单!
else
密码修改成功,请牢记!
fetchmoney()
floatm;
charch;
输入取款金额:
¥>
endl;
if(money<
m)
对不起,你的余额不足!
else
{money=money-m;
操作成功,请收好钱!
是否要继续该项操作:
(Y/N)"
ch;
while(ch!
='
n'
ch!
N'
Y'
y'
)//选择错误时判定
}while(ch=='
||ch=='
savemoney()//存钱函数功能实现
floatc;
charch;
请输入要存入的金额:
c;
while(c<
输入错误,请重新输入!
money=money+c;
操作已成功!
)
intYH:
acnum=0;
display()//用户信息界面
#####################################"
#"
# 用户姓名:
# 帐号:
"
# 余额:
"
#按输入键回到上一菜单"
exitYH()//退出系统
感谢您对本银行的支持,欢迎下次光临!
exit(0);
}青山埋白骨,绿水吊忠魂。