c++图书 银行账户管理系统mis系统

银行账户管理系统 #include #include #include #include using namespace std;

void handle_menu(); int menu_select();

class account{ protected:

char num[50];//帐号 char name[20];//姓名 char id[50];//身份证号 double money;//余额 public:

account(){} ~account(){}

void setnum(char s[]){strcpy(num,s);} char *getnum(){return num;} void setname(char n[]){strcpy(name,n);} char *getname(){return name;} void setid(char idn[]){strcpy(id,idn);} char *getid(){return id;} void setmoney(float m){money=m;}

double getmoney(){return money;}

void disp() { cout<<\

<

<

} };

class bankmanager{ protected:

vectorvaccount; public:

bankmanager(){} ~bankmanager(){} void readfile(); void writefile(); void addin(); //开户 void display(); void find();//查询 void del();//销户 void modify();//修改 void savemoney();//存款 void delmoney();//取款 };

#include\ void bankmanager::readfile() { vector::iterator p; p=vaccount.begin(); ifstream in(\ account ac; while(in.read((char*)&ac,sizeof(ac))) { *p=ac; p++; }

in.close(); }

void bankmanager::writefile()

{ ofstream out(\ for(int i=0;i

vaccount[i]));}

out.close(); }

void bankmanager::addin() { //readfile();

char anum[50],aname[50],aid[50]; double am; account a; for(;;) { cout<<\请输入账户息:\ cout<<\帐号(以0结束):\ cin.getline(anum,'\\n');

if(anum[0]=='0') break; a.setnum(anum); cout<<\姓名:\ cin.getline(aname,'\\n'); a.setname(aname); cout<<\身份证号:\ cin.getline(aid,'\\n'); a.setid(aid); cout<<\金额:\ cin>>am; getchar(); a.setmoney(am); vaccount.push_back(a); }

writefile(); }

void bankmanager::display () {

readfile();

cout<<\帐号\姓名\

<<\身份证号\金额\ for(int i=0;i

void bankmanager::find()

{ readfile();

char anum[20];

cout<<\请输入查询的帐号:\ cin.getline(anum,'\\n');

for(int i=0;i

信息如下:\

cout<<\帐号\

<<\姓名\身份证号\<<\金额\

vaccount[i].disp(); break; } }

if(i>=vaccount.size())

cout<<\不存在要查询的账户信息!\}

void bankmanager::del() {readfile();

vector::iterator p; char anum[20]; p=vaccount.begin();

cout<<\请输入图书编号:\ cin.getline(anum,'\\n');

for(int i=0;i

{cout<<\要删除的帐号

信息如下:\

cout<<\帐号\

<<\姓名\身份证号\<<\金额\

vaccount[i].disp(); vaccount.erase(p+i); cout<<\删除成功1\ break; } }

if(i>=vaccount.size())

cout<<\不存在要删除的

帐号信息!\

writefile(); }

void bankmanager::modify () {readfile(); double am;

char anum[20],aname[20],aid[20]; cout<<\请输入要修改的账号:\ cin.getline(anum,'\\n');

for(int i=0;i

{if(strcmp(vaccount[i].getnum(),anum)==0) { cout<<\要修改的帐号信息如下:\ vaccount[i].disp();

cout<<\请输入帐号信息:\ cout<<\帐号:\

cin.getline(anum,'\\n'); vaccount[i].setnum(anum);

cout<<\姓名:\ cin.getline(aname,'\\n');

vaccount[i].setname(aname); cout<<\身份证号:\ cin.getline(aid,'\\n'); vaccount[i].setid(aid);

cout<<\金额:\ cin>>am; getchar();

vaccount[i].setmoney(am); } }

writefile();

cout<<\成功修改!\ }

void bankmanager::savemoney () { readfile();

double am,bm; char anum[20];

cout<<\请输入要存款的帐号:\ cin.getline(anum,'\\n');

for(int i=0;i

{if(strcmp(vaccount[i].getnum(),anum)==0) { cout<<\要存款的帐号信息如下:\

vaccount[i].disp();

am=vaccount[i].getmoney (); cout<<\请输入存款金额:\ cin>>bm; getchar();

vaccount[i].setmoney(am+bm); } }

writefile();

cout<<\存款完成!\}

void bankmanager::delmoney() { readfile();

double am,bm; char anum[20];

cout<<\请输入要取款的帐号:\ cin.getline(anum,'\\n');

for(int i=0;i

{if(strcmp(vaccount[i].getnum(),anum)==0) { cout<<\要取款的帐号信息如下:\

vaccount[i].disp();

am=vaccount[i].getmoney (); cout<<\请输入取款金额:\ cin>>bm; getchar();

vaccount[i].setmoney(am-bm); } }

writefile();

cout<<\取款完成!\}

int menu_select() {char s[2]; int cn;

cout<<\增加帐号记录\\n\ cout<<\修改帐号记录\\n\ cout<<\查询帐号记录\\n\ cout<<\删除帐号记录\\n\ cout<<\显示帐号记录\\n\ cout<<\存款\\n\ cout<<\取款\\n\ cout<<\退出系统\\n\ cout<<\请选择1-8:\ for(;;) { gets(s); cn=atoi(s); if(cn<1||cn>8)

printf(\输入错误,重选1-8:\

else break; }

return cn; }

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4