银行帐户管理程序(功能完善版)_第1页
银行帐户管理程序(功能完善版)_第2页
银行帐户管理程序(功能完善版)_第3页
银行帐户管理程序(功能完善版)_第4页
银行帐户管理程序(功能完善版)_第5页
已阅读5页,还剩12页未读 继续免费阅读

下载本文档

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

文档简介

1、/ 2.cpp :定义控制台应用程序的入口点。/#i nclude stdafx.h#in clude#in elude #in clude#i nclude #in clude #i nclude #in clude using n amespace std;class con sumer;class YH/银行类public:void set_accou nt(); 银行开户功能void del_accou nt();/ 注销账户功能void tran sfer(i nt);/ 转账功能void en ter_accou nt(); /进入用户个人信息功能void addmo ney(i

2、nt,float);存款功能void exitYH();退出系统void function show();void save();void load();/功能界面con sumer *acco un t1000;static int aenum; 账户数;class consumer:public YH/用户类,继承银行类的属性public:frie nd class YH;con sumer(i nt id,stri ng Name,stri ng PassWord,float m,i nt idcard,i nt phon e,i nt cunqian, char tmp100,i nt

3、 quqia n, char tmp1100,i nt zhua nzha ng,char tmp2100) ID=id; name=Name;m on ey=m;passwd=PassWord;idc=idcard;pho=ph one; cq=c unqian;qq=quqia n;zz=zhuanzhang;strcpy_s(TMP,tmp);strcpy_s(TMP1,tmp);z.strcpy_s(TMP2,tmp);con sumer()ID=0; name=0;mo ney=0;passwd=0;idc=0;pho=0;cq=0;strcpy_s(TMP,0);qq=0;strc

4、py_s(TMP1,0);zz=0;strcpy_s(TMP2,0);构造函数初始化int get_id()return ID;int get_idcard()return idc;int get_ph on e()return pho;void save mon ey();/ 存stri ng get_passwd()retur n passwd;/取得密码void display。;/ 个人信息界面 void display1();/查询记录界面void display2();void display3();void display4();void fetchmoney();/ 取void

5、 cha nge_passwd();void add_ mon ey(float);void dec_ mon ey(float);float get_mon ey();/ 卡卡转帐private:int ID; /开户帐号stri ng passwd; / 用户密码stri ng n ame; /用户姓名float money;/ 开户金额int idc;int pho;char TMP100,TMP1100,TMP2100;int cq,qq,zz;void YH:save()ofstream ofile(ba nkdat.dat,ios:out);ofstream outfile(ba

6、nkdat.dat,ios:out);int n=0;outfileac num;for(n=0;nacnum;n+)e ndl;e ndl;e ndl;e ndl;e ndl;e ndl;e ndl;e ndl;e ndl;e ndl;e ndl;e ndl;outfileID outfilemon ey outfilen ame outfilepasswd outfileidc outfilepho outfilecq outfileqq outfilezz outfileTMP outfileTMP1 outfileTMP2 outfile.close();/*读入用户信息功能实现*/v

7、oid YH:load()ifstream in file(ba nkdat.dat,ios:i n);if(!i nfile)cerr读取错误,无资料中!ac num;for(n=0;nid;in filem;in file n am;in filepassw;in fileidcard;in fileph one;in filec unqian;in filequqia n;in filezhua nzha ng;in filetmp;in filetmp1;in filetmp2;acco un t n-passwd;con sumer*acc=newcon sumer(id, nam,

8、passw,m,idcard,ph on e,c unqian ,tmp,quqia n,tmp1,zhua nzha ng,tmp2);acco un t n = acc;in file.close();cout读取资料正常!endl;/*转账功能实现*/void YH:tra nsfer(i nt x)int id;cout id;int flag = 1;int i = 0;while(iget_id() flag = 0; elseif(flag)cout帐号不存在!endlendl; return ;float b;coute ndl b;while(b=0)cout请输入正确的数字

9、!endl;cout b;if(accountx-get_money()b) cout对不起,金额不够!dec_ mon ey(b);acco un ti-add_ mon ey(b);acco un tx-zz=b;time_t t3 = time(0); time_t是结构体,包含在 time.h 中,%Astrftime( accoun tx-TMP2,sizeof(acco untx-TMP2),%Y/%m/%d %X,localtime(&t3);size_t strftime(char *strDest, size_t maxsize, const char *format, co

10、nst struct tm *timeptr);cout转账成功! endl;for(i nt j=O;j mon ey=acco un tx- mon ey-y; float con sumer:get_ mon ey()retur n mon ey; void mai n()YH yh;con sumer c1;yh.fu nctio nshow(); /*主界面显示*/void YH:fu ncti on show()double n;int t;dosystem(cls); load();coute ndl请输入相应的操作序号进行操作:e ndl;cout*e ndl;coutcout

11、1账户注册e ndl;coutcoute ndl;2.账户登录e ndl;e ndl;coute ndl;cout3.账户注销endl;coutcoutcout4.退出系统e ndl;e ndl;e ndl;cout*e ndl;cout t ;cinn;while( n 4)cout操作错误,请输入正确的操作序号!endl;cout t ;cinn;while(1)if(n-(i nt)n=0) t=n; break;else cout操作错误,请输入正确的操作序号!endl;cout t ;cinn;switch(t)case 1: set_account(); 开户 break;case

12、 2:enter_account(); 登录 break;case 3: del_account(); 注销break;case 4: exitYH(); 退出 break;cin.get(); /接收输入一行字符串 while(true);void YH:e nter_accou nt()登陆账号int id;cout id;int flag = 1;int i = 0;/_page_breakwhile(iget_id() flag = 0; elsei+;if(flag)cout帐号不存在!endlendl;return;cout passw;if(passw!=acco un ti-g

13、et_passwd()cout密码错误,请重新操作!;for(i nt j=0;jdisplay();cin .get();ci n.get(); double n;int t,r;dosystem(cls);cout请选择下列操作:endl;coute ndl;cout1查看账户信息e ndl;coute ndl;cout2.取款e ndl;coute ndl;cout3.存款e ndl;coute ndl;cout4.修改密码e ndl;coute ndl;cout5.转账e ndl;coute ndl;cout6.查询存取款转账记录e ndl;coute ndl;cout7.返回上一菜单

14、e ndl;cout*e ndl;cout*e ndl;cout t ;cinn;while( n7)cout操作错误,请输入正确的操作序号!e ndl;cout t ;cinn;while(1)if(n-(i nt)n=0)!e ndl; t=n; break;else cout操作错误,请输入正确的操作序号 coutdisplay();break;case 2: acco un ti-fetchm on ey();save();break;case 3:acco un ti-savem on ey();save();break;case 4:acco un ti-cha nge_passw

15、d();save();break;case 5:tra nsfer(i);save();break;case 6:acco un ti-display1(); cinr;switch(r)case 1: acco un ti-display2();break;case 2: acco un ti-display3();break;case 3:acco un ti-display4();break;case 4:return;break;case 7:retur n;cin .get();ci n.get();while(1);void YH:set_accou nt()开户int id,c

16、unqian,qu qia n, zhua nzha ng; char tmp100,tmp1100,tmp2100; stri ng n am;stri ng passw;float m;int idcard,ph one;int flag = 1;int i = 0;coute ndl请输入数字账户号: id;while(iget_id()flag = 0;cout该帐号已存在,请重新输入 !endl; for(i nt j=O;j=1OOOOOOOOO;j+);延时功能return;else i+;请输入开户人姓名:请输入开户密码:请输入存入金额:coute ndl cinn am;co

17、ute ndl passw;coute ndl cinm;while(m=0)cout 请输入正确的数字!e ndl;cinm;coute ndl idcard;coute ndl pho ne;cunqian=0;time_t t1 = time(0); time_t是结构体,包含在 time.h 中,strftime( tmp, sizeof(tmp), %Y/%m/%d %X %A ,localtime(&t1);size_t strftime(char *strDest, size_t maxsize, const char *format, const struct tm *time

18、ptr);quqia n=0;time_t t2 = time(0); /time_t是结构体,包含在 time.h 中,strftime( tmpl, sizeof(tmpl), %Y/%m/%d %X %A ,localtime( &t2);struct tmstruct tmnewsize_t strftime(char *strDest, size_t maxsize, const char *format, const *timeptr);zhuanzhang=0;time_t t3 = time(0); time_t是结构体,包含在 time.h 中,strftime( tmp2,

19、 sizeof(tmp2), %Y/%m/%d %X %A ,localtime(&);size_t strftime(char *strDest, size_t maxsize, const char *format, const *timeptr);con sumer*acc=con sumer(id, nam,passw,m,idcard,ph on e,c unqian ,tmp,quqia n,tmp1,zhua nzha ng,tmp2); acco un tac num = acc;cout开户成功!endlendl;acnu m+;save();cin .get();retur

20、n;void YH:del_accou nt()账号注销int id;coute ndl id;int flag = 1;int i = 0;while(iget_id()flag = 0;elsei+;if(flag)cout该帐号不存在,请重新操作!endl;for(i nt j=O;j=1OOOOOOOOO;j+);延时功能return;cout passw;if(passw!=acco un ti-get_passwd()cout密码或账号错误,请重新操作! ;for(i nt j=0;j=1000000000;j+);延时功能return;for(i nt j=i;jac nu m;

21、j+)acco un tj = acco un tj+1;acco un tac nu m-1=NULL;acnu m-;cout你的账号已注销!!endlendl; save();cin .get();return;void con sumer:cha nge_passwd()修改密码stri ng pwd,repwd;cout pwd;cout repwd;if(pwd!=repwd)!e ndl;cout你输入的两次密码不一样,按输入键返回上一层菜单elsecout密码修改成功,请牢记 !endl;passwd=repwd;cin .get();void con sumer:fetchm

22、 on ey()取函数float m;char ch;docoutendl输入取款金额:endl ;cinm;while(m=0)cout请输入正确的数字!endl;COUt T;cinm;if(mon eym)cout对不起,你的余额不足!endl;elsemon ey=mon ey-m;qq=m;time_t t2 = time(0); time_t是结构体,包含在 time.h 中,strftime( TMP1, sizeof(TMP1), %Y/%m/%d %X %A ,localtime(&t2);size_t strftime(char *strDest, size_t maxsi

23、ze, const char *format, const struct tm *timeptr);coute ndl操作成功,请收好!e ndl;cout是否要继续该项操作:(Y/N)e ndl;cout ch;while(ch!= n&ch!=N&ch!=Y&ch!=y)/选择错误时判定cout ch;while(ch=y|ch=Y);void con sumer:save mon ey()/存函数功能实现char ch;int c;docoutendl请输入要存入的金额: c;while(c=0)cout输入错误,请重新输入!endl;COUt c;mon ey=mon ey+c;cq=

24、c;time_t t1 = time(0); time_t是结构体,包含在 time.h 中,strftime( TMP, sizeof(TMP), %Y/%m/%d %X %A ,localtime( &t1);size_t strftime(char *strDest, size_t maxsize, const char *format, const struct tm *timeptr);cout操作已成功!endl;cout是否要继续该项操作:(Y/N) endl;cout ch;while(ch!= n&ch!=N&ch!=Y&ch!=y)cout ch;while(ch=y|ch

25、=Y);int YH:ac num=0;void con sumer:display()用户信息界面system(cls);cout#e ndl;coute ndl;cout用户姓名:n amee ndl;coute ndl;cout帐号:IDendl;coute ndl;cout余额: mon eye ndl;coute ndl;cout身份证号:idce ndl;coute ndl;cout: phoendl;coute ndl;cout按输入键进入操作界面e ndl;coute ndl;cout#e ndl;cout t ;void con sumer:display1()system(cls); cout#e ndl; coute ndl;cout1.存记录endl;coute ndl;coute ndl;cout2.取记录endl;coute ndl;coute ndl;cout3.转账记录endl;coute ndl;coute ndl;cout按输入键返回

温馨提示

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

评论

0/150

提交评论