欢迎来到天天文库
浏览记录
ID:32534241
大小:81.80 KB
页数:7页
时间:2019-02-11
《atm自动取款机模拟程序》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、银行ATM自动取款机模拟程序本程序需要两个文件,ATM程序文件及系统管理员管理,两个文件必须在同一个文件或同一路径下!1.ATM程序文件://////CUser.h//////////#includeusingnamespacestd;structuser{intMoney;intUser;intPassword;};classCAtm{public:intLogin();//登陆voidGetBalance();//查询余额voidChangePassword();//修改密码voidDr
2、awMoney();//取款voidTranserAccounts();//转账voidBankSaving();//存款intExit();//退出系统private:intPosition;//数据位置userus[5];//保存文件内容userus[20];users;};///////////User.cpp/////////////#include#include#include"CUser.h"usingnamespacestd;intCAtm::Login(
3、)//登录{intsave[5];//保存被吃卡的用户的账号boolflag;inti,j,k,num;fstreamiofile("atm.dat",ios::in
4、ios::binary);iofile.read((char*)&us,sizeof(us));fstreamin("jiesuo.dat",ios::in
5、ios::out
6、ios::binary);in.read((char*)&save,sizeof(save));cout<<"请输入你的账号:";cin>>num;flag=true;f
7、or(i=0;i<5;i++){if(us[i].User==num){flag=false;j=i;}}if(flag==true){cout<<"账号不存在!"<>num;for(i=1;i<=3;i++){k++;if(us[j].Password!=nu
8、m){if(k==3){cout<<"你的卡被锁定了,请找系统管理员解锁!"<9、ios::binary);out.write((char*)&save,sizeof(save));out.close();return0;}else{cout<<"请重新输入密码:";cin>>num;}}}cout<<"密码正确,进入系统!"<10、.Money=us[j].Money;s.Password=us[j].Password;Position=j;iofile.close();return1;}voidCAtm::GetBalance()//查询余额{cout<<"您的账户余额:"<11、ios::out12、ios::binary);cout<<"请输入新密码:";cin>>s.Passwo13、rd;iofile.seekp((Position+1)*sizeof(s),ios::beg);iofile.write((char*)&s,sizeof(s));iofile.close();}voidCAtm::DrawMoney()//取款{intj;cout<<"请输入取款金额:";cin>>j;while(j>s.Money){cout<<"金额不足,请重新输入取款金额:";cin>>j;}s.Money=s.Money-j;fstreamiofile("atm.dat",ios::in14、ios:15、:out16、ios::binary);iofile.seekp((Position+1)*sizeof(s),ios::beg);iofile.write((char*)&s,sizeof(s));cout<<"取款金额是:"<
9、ios::binary);out.write((char*)&save,sizeof(save));out.close();return0;}else{cout<<"请重新输入密码:";cin>>num;}}}cout<<"密码正确,进入系统!"<10、.Money=us[j].Money;s.Password=us[j].Password;Position=j;iofile.close();return1;}voidCAtm::GetBalance()//查询余额{cout<<"您的账户余额:"<11、ios::out12、ios::binary);cout<<"请输入新密码:";cin>>s.Passwo13、rd;iofile.seekp((Position+1)*sizeof(s),ios::beg);iofile.write((char*)&s,sizeof(s));iofile.close();}voidCAtm::DrawMoney()//取款{intj;cout<<"请输入取款金额:";cin>>j;while(j>s.Money){cout<<"金额不足,请重新输入取款金额:";cin>>j;}s.Money=s.Money-j;fstreamiofile("atm.dat",ios::in14、ios:15、:out16、ios::binary);iofile.seekp((Position+1)*sizeof(s),ios::beg);iofile.write((char*)&s,sizeof(s));cout<<"取款金额是:"<
10、.Money=us[j].Money;s.Password=us[j].Password;Position=j;iofile.close();return1;}voidCAtm::GetBalance()//查询余额{cout<<"您的账户余额:"<11、ios::out12、ios::binary);cout<<"请输入新密码:";cin>>s.Passwo13、rd;iofile.seekp((Position+1)*sizeof(s),ios::beg);iofile.write((char*)&s,sizeof(s));iofile.close();}voidCAtm::DrawMoney()//取款{intj;cout<<"请输入取款金额:";cin>>j;while(j>s.Money){cout<<"金额不足,请重新输入取款金额:";cin>>j;}s.Money=s.Money-j;fstreamiofile("atm.dat",ios::in14、ios:15、:out16、ios::binary);iofile.seekp((Position+1)*sizeof(s),ios::beg);iofile.write((char*)&s,sizeof(s));cout<<"取款金额是:"<
11、ios::out
12、ios::binary);cout<<"请输入新密码:";cin>>s.Passwo
13、rd;iofile.seekp((Position+1)*sizeof(s),ios::beg);iofile.write((char*)&s,sizeof(s));iofile.close();}voidCAtm::DrawMoney()//取款{intj;cout<<"请输入取款金额:";cin>>j;while(j>s.Money){cout<<"金额不足,请重新输入取款金额:";cin>>j;}s.Money=s.Money-j;fstreamiofile("atm.dat",ios::in
14、ios:
15、:out
16、ios::binary);iofile.seekp((Position+1)*sizeof(s),ios::beg);iofile.write((char*)&s,sizeof(s));cout<<"取款金额是:"<
此文档下载收益归作者所有