银行管理系统c++代码python_Bank Simulation Program银行管理系统C++ :)

设计并实现简单的银行存取款系统,系统主界面包括登录和注册两个选项,选择登录,提示用户输入银行帐号和密码,验证通过后进入主界面,主界面包括:存款、取款、查询余额、历史记录、修改密码等功能。注册功能让用户输入账号和密码,在注册时要验证账号是否已经存在。所有数据能够保存在文件中,退出系统后再次运行系统,之前注册的用户和存款信息都存在。

#include

#include

#include

#include

using namespace std;

struct user;

typedef user T;

queue uu;

int count=0;

struct user

{

string id;

string pass;

int n;

double *money;

user() {}

user(string id,string pass,int n,double *money):id(id),pass(pass),n(n),money(money) {}

};

int gongshow();

int gong(string newid);

int save(string newid, string newpass);

int setid(string newid,string newpass);

int main()

{

system("color 0A");

while(1)

{

int m;

string newid,newpass;

cout << "\t\t\t *************************" << endl;

cout << "\t\t\t *Bank Simulation Program*" << endl;

cout << "\t\t\t *************************" << endl;

cout << "\t\t\t * *" << endl;

cout << "\t\t\t * 1.LOG IN *" << endl;

cout << "\t\t\t * 2.ENROLL *" << endl;

cout << "\t\t\t * 3.ESC *" << endl;

cout << "\t\t\t * *" << endl;

cout << "\t\t\t *************************" << endl<

cout << "\t\t\t Please enter the serial number:";

cin >> m;

if(m==3)

return 0;

system("cls");

cout << "\t\t\t *************************" << endl;

cout << "\t\t\t *Bank Simulation Program*" << endl;

cout << "\t\t\t *************************" << endl<

cout << "\t\t\t ID:";

cin >> newid;

cout << "\t\t\t PASSWORD:";

cin >> newpass;

int x=save(newid,newpass);// id 1 password 0 no_id 2

if(m==1)

if(x==1)

{

cout << "\t\t\t LOGIN SUCCESSFUL";

system ("pause>nul");

system("cls");

while(1)

{

if(gong(newid)==0) break;

int x=save(newid,newpass);

system ("pause>nul");

system("cls");

}

}

else if(x==2)

{

cout << "\t\t\t ACCOUNT DOS'T EXIST";

system ("pause>nul");

system("cls");

}

else

{

cout << "\t\t\t WRONG PASSWORD";

system ("pause>nul");

system("cls");

}

else if(m==2)

{

if(x==2)

{

if(setid(newid,newpass))

{

cout << "\t\t\t ENROLL SUCCESS";

while(1)

{

while(!uu.empty()) uu.pop();

int x=save(newid,newpass);

system ("pause>nul");

system("cls");

if(gong(newid)==0) break;

}

}

else

{

cout << "\t\t\t ENROLL FAILURE";

system ("pause>nul");

system("cls");

}

}

else if(x==1)

{

cout << "\t\t\t ACCOUNT ALREADY EXISTS";

system ("pause>nul");

system("cls");

}

system("cls");

}

}

return 0;

}

int gongshow()

{

cout << "\t\t\t *************************" << endl;

cout << "\t\t\t *Bank Simulation Program*" << endl;

cout << "\t\t\t *************************" << endl;

cout << "\t\t\t * *" << endl;

cout << "\t\t\t * 1.DPOSIT *" << endl;

cout << "\t\t\t * 2.WITHDRAWALS *" << endl;

cout << "\t\t\t * 3.CHECK BALANCES *" << endl;

cout << "\t\t\t * 4.HISTORY RECORD *" << endl;

cout << "\t\t\t * 5.CHANGE PASSWORD *" << endl;

cout << "\t\t\t * 6.ESC *" << endl;

cout << "\t\t\t * *" << endl;

cout << "\t\t\t *************************" << endl;

cout << endl << "\t\t\t Please enter the serial number:";

int n;

cin >>n;

return n;

}

int gong(string newid)

{

int n=gongshow();

if(n==2||n==1||n==5)

{

fstream f("ios.txt",ios::out);

if(n==1)

{

double n=0;

cout << "\t\t\t Enter deposit amount:";

cin >> n;

while(!uu.empty())

{

if(uu.front().id==newid)

{

f<

for(int i=0; i

{

f<< uu.front().money[i]<

}

f<< uu.front().money[uu.front().n-1]+n<< endl;

cout << "\t\t\t Deposit has been successful";

}

else

{

f<

for(int i=0; i

{

f<< uu.front().money[i]<

}

f<

}

uu.pop();

count--;

if(count==1)

uu.pop();

}

}

if(n==2)

{

double n=0;

cout << "\t\t\t Enter the withdrawal amount:";

cin >> n;

while(!uu.empty())

{

if(uu.front().id==newid&&uu.front().money[uu.front().n-1]-n>=0)

{

f<

for(int i=0; i

{

f<< uu.front().money[i]<

}

f<< uu.front().money[uu.front().n-1]-n<< endl;

f<< endl;

cout << "\t\t\t Withdrawals success";

}

else if(uu.front().id!=newid)

{

f<

for(int i=0; i

{

f<< uu.front().money[i]<

}

f<

}

else if(uu.front().id==newid&&uu.front().money[uu.front().n-1]-n<0)

{

f<

for(int i=0; i

{

f<< uu.front().money[i]<

}

f<

cout << "\t\t\t INSUFFICIENT BALANCE\n";

}

uu.pop();

count--;

if(count==1)

uu.pop();

}

}

else if(n==5)

{

string newpass;

cout << "\t\t\t Please enter a new password:";

cin >> newpass;

while(!uu.empty())

{

if(uu.front().id==newid)

{

f<

for(int i=0; i

{

f<< uu.front().money[i]<

}

f<< uu.front().money[uu.front().n-1]<< endl;

}

uu.pop();

count--;

if(count==1)

uu.pop();

}

cout << "\t\t\t PASSWORD RESET COMPLETE\n";

}

f.close();

}

else if(n==3)

{

while(!uu.empty())

{

if(uu.front().id==newid)

{

cout << "\t\t\t BALANCES:" << uu.front().money[uu.front().n-1]<

}

uu.pop();

}

}

else if(n==4)

{

while(!uu.empty())

{

if(uu.front().id==newid)

{

cout<

for(int i=1; i

{

cout<

double difference=uu.front().money[i]-uu.front().money[i-1];

if(difference>0)

cout<

cout<

}

if(uu.front().n==1) cout<

}

uu.pop();

}

}

else if(n==6)

{

system("cls");

return 0;

}

return 1;

}

int save(string newid, string newpass)

{

count=0;

int flog=2;

fstream fi;

fi.open("ios.txt",ios::in);

if(!fi)

{

fi.open("ios.txt",ios::out);

fi.close();

fi.open("ios.txt",ios::in);

}

while(!fi.eof())

{

double *money=new double;

user a;

fi >> a.id >> a.pass >> a.n;

if(a.id==newid)

if(a.pass==newpass)

flog=1;

else

return 0;

for(int j =0; j

{

fi >> money[j];

}

a.money=money;

uu.push(a);

count++;

}

fi.close();

return flog;

}

int setid(string newid,string newpass)

{

fstream fi("ios.txt",ios::app|ios::out);

int n=1;

double x=0.0;

fi<< newid << ' ' << newpass << ' ' << n << ' ' << x <

fi.close();

return 1;

}

到这里就写完了 :) .

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值