银行模拟管理系统源代码

#include <iostream.h>
#include <string.h>
#include   <stdlib.h>  
#include   <time.h>
#include <windows.h>


#define OD 2000  //透支额OVERDRAFT
#define CD 30/100  //信用度creditdegree
#define M 50  //可存储的帐户最多个数

void face(int n)
{
 char * string[]={"",
                "\t┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓",
                "\t┃         ┏┯┓┏┯┓┏┯┓┏┯┓┏┯┓┏┯┓┏┯┓           ┃",
       "\t┃         ┠ C┨┠ +┨┠ +┨┠实┨┠训┨┠课┨┠程┨           ┃",
       "\t┃         ┗┷┛┗┷┛┗┷┛┗┷┛┗┷┛┗┷┛┗┷┛           ┃",
                "\t┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫",
       "\t┃                      银行管理系统                            ┃",
       "\t┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫",
       "\t┃                                                              ┃",
                "\t┃              操作方法:(请输入以下数字进行!)                  ┃",
       "\t┃                                                              ┃",
          "\t┃  ------------------欢迎进入MQS银行管理系统-----------------  ┃",
       "\t┃                                                              ┃",
       "\t┃                     A、存折用户                              ┃",
       "\t┃                                                              ┃",
       "\t┃                     B、信用卡用户                            ┃",
       "\t┃                                                              ┃",
          "\t┃                     0、退出系统                              ┃",
       "\t┃                                                              ┃", 
       "\t┃                                                              ┃", 
       "\t┃                                                              ┃", 
       "\t┃                                                              ┃", 
       "\t┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫",
       "\t┃       OO════∩════OO                             ┃",
       "\t┃             ╭╬╮          ◢                  ┃",
       "\t┃       .▁╭▅▆▇□□█▇▆▅▄▃▂▁(╳)█╮               ┃",
       "\t┃        ╰═▃_网络09班▁∠════▔▔▔                   ┃",
       "\t┃      *:-.,,.-:*``*:-.,,.-:*``*:-.,,.-:*``*:-.,,.-:*,,        ┃",
       "\t┃   ╭-╧-╮╭╧╮╭╧╮╭╧╮╭╧╮ *:-.,,.-:*,、☆*:-.,:     ┃",
       "\t┃   ║C++ ║║程║║序║║设║║计║    ★*:-.,             ┃",
       "\t┃    └﹏┘ └﹏┘└﹏┘└﹏┘└﹏┘                    ┃",
       "\t┃            程序设计:银行模拟系统   学生: 马庆帅              ┃",
       "\t┃            指导老师:赵耀军  常 娟                            ┃",
                   "\t┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛"};
     if(n>=0)
  {
    for(int i=34;i>0;i--)
    {
       system("cls");                           

     for(int j=i;j<34;j++)
      cout<<string[j]<<endl;
     Sleep(n);                                          }
  }
     else
  {
    system("cls");
    for(int i=0;i<34;i++)
     cout<<string[i]<<endl;

  }
 

void suijishu()
{
 
    int i,j;
    srand((int)time(0));
    for(i=0;i<10;i++)
    {
     j=rand()%9;
     cout<<j;
    }
}


/**void show1(void)

    cout<<"\n☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆";
 cout<<"\n           -----------------欢迎进入MQS银行管理系统--------"<<endl;
 cout<<"           ||                                               ||"<<endl;
 cout<<"           ||                                               ||"<<endl;
 cout<<"           ||                A、存折用户                    ||"<<endl;
 cout<<"           ||                                               ||"<<endl;
 cout<<"           ||                B、信用卡用户                  ||"<<endl;
 cout<<"           ||                                               ||"<<endl;
 cout<<"           --------------------------------------------------"<<endl;
 cout<<"☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆\n\n";
 cout<<"      请选择你的卡类型:";
 }
**/
void show2(void)
{
    cout<<"\n☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆";
 cout<<"           ---------------------------------------------------"<<endl;
 cout<<"           ||                                               ||"<<endl;
 cout<<"           ||                                               ||"<<endl;
 cout<<"           ||                1、新开账户                    ||"<<endl;
 cout<<"           ||                                               ||"<<endl;
 cout<<"           ||                2、已有账号                    ||"<<endl;
 cout<<"           ||                                               ||"<<endl;
 cout<<"           ||                0、回到上一级菜单              ||"<<endl;
 cout<<"           ||                                               ||"<<endl;
 cout<<"           --------------------------------------------------"<<endl;
 cout<<"☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆"<<endl<<endl;
 cout<<"      请选择操作:";

}
void show3(void)
{
    cout<<"\n☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆";
 cout<<"           -------------------------------------------------"<<endl;
 cout<<"           ||                                               ||"<<endl;
 cout<<"           ||                                               ||"<<endl;
 cout<<"           ||                1、查询余额                    ||"<<endl;
 cout<<"           ||                2、取款                        ||"<<endl;
 cout<<"           ||                3、存款                        ||"<<endl;
 cout<<"           ||                4、修改密码                    ||"<<endl;
 cout<<"           ||                5、删除用户                    ||"<<endl;
 cout<<"           ||                0、回到上一级菜单              ||"<<endl;
 cout<<"           ||                                               ||"<<endl;
 cout<<"           --------------------------------------------------"<<endl;
 cout<<"☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆\n\n";
 cout<<"      请选择操作:";
}

// 以下为程序正式开始部分
int t=0;  
int q=0;       //记录银行户数目:存折和信用卡均算
int h;

class BankCard     //定义存折类
{
public:
   unsigned long   password;       //密码
   double   balance;            //余额
   unsigned long   cardnumber;          //卡号
   BankCard(){}                 //构造函数
   void newcard();                //新开帐户
   double getmoney();               //银行卡取款
   double inmoney();                                 //存款
   double findbalance();                              //查询余额
   unsigned long changepw(unsigned long x);           //修改密码
   void dele(int x,unsigned long y,double z);         //删除存折用户
};BankCard B[M];


 //定义信用卡类

class CreditCard:public BankCard       
{
public:
      double findbalance2();       //信用卡查询余额
      void newcard2();             //信用卡新开帐户
   double getmoney2();          //信用卡取款
   void dele2(int x,unsigned long y,double z);         //删除信用卡用户
};CreditCard C[M];
 
double BankCard::getmoney()   //存折取款
{
  double l;
     cout<<"    -----------------取款操作-------------------\n";
lab4:cout<<"\n    请输入要取的款额:";
     cin>>l;
  if(l>balance)
  {
   cout<<"     对不起,你的余额不足,请重新输入:"; goto lab4;
  }
     balance=balance-l;
     cout<<"    操作成功,谢谢使用!!\n    按任意键+enter或者0返回:  ";
  return balance;
}

double CreditCard::getmoney2()//信用卡取款
{
  double l;
     cout<<"    -----------------取款操作-------------------\n";
lab4:cout<<"    \n请输入要取的款额:";
     cin>>l;
  if(l>(OD*CD+balance))
  {
   cout<<"    对不起,你的余额不足,请重新输入:"; goto lab4;
  }
     balance=balance-l;
     cout<<"     操作成功,谢谢使用!!\n    按任意键+enter或者0返回:  ";
  return balance;
}

double BankCard::inmoney()               //存款
     {
              double l;
                 cout<<"     -----------------存款操作-------------------\n";
                 cout<<"\n    请输入要存的款额:";
                 cin>>l;
                 balance=balance+l;
     return balance;
     }
 
double BankCard::findbalance()             //存折查询余额
{
 cout<<"     -----------------存折查询余额操作-------------------\n"<<endl;  
 cout<<"     您的余额是: "<<balance<<endl;
 cout<<"     操作成功,谢谢使用!!\n    按任意键+enter或者0返回:  ";
 return balance;
}


double CreditCard::findbalance2()         //信用卡查询余额
{
 double m=OD*CD+balance;
 cout<<"    -----------------信用卡查询余额操作-------------------\n"<<endl;  
 cout<<"    信用卡查询余额:\n您的余额是: "<<balance+OD<<"\n其中可取款额为: "<<m<<endl;
 cout<<"    操作成功,谢谢使用!!\n    按任意键+enter或者0返回:  ";
 return balance;
}

void BankCard::newcard()   //存折新开帐户

 unsigned long x,y,y1,y2;int k=1;
    double z;
//x=Random[1000000001,999999999] ;
x=6465987613+(5+q)*t; 

Paw1: do
 {
  cout<<"    ------------新开存折帐户--------------------\n";
  cout<<"\n    请输入一个6位数字组成的密码:";
  cin>>y1;
       if(y1<99999||y1>1000000)
   {
    
    cout<<"\n☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆";
 cout<<"           -------------------------------------------------"<<endl;
 cout<<"           ||                                               ||"<<endl;
 cout<<"           ||                                               ||"<<endl;
 cout<<"           ||                   Wrong!!!                    ||"<<endl;
 cout<<"           ||                                               ||"<<endl;
 cout<<"           ||                输入无效的密码!!!              ||"<<endl;
 cout<<"           ||                                               ||"<<endl;
 cout<<"           ||                请重新设定                     ||"<<endl;
 cout<<"           ||                                               ||"<<endl;
 cout<<"           ||                                               ||"<<endl;
 cout<<"           --------------------------------------------------"<<endl;
 cout<<"☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆\n\n";
  
    goto Paw1;
   }
        cout<<"    请再次输入密码:";
        cin>>y2;
        if(y1==y2) {y=y1;k=1;}
        else
  {  cout<<"    两次输入的密码不相同,请再次输入。\n";k=0;}
 } while(k==0);
 cout<<"    请输入开户金额: ";cin>>z;
    cout<<"    请存入现金\n    处理中,请稍后………………\n"<<"     您新开的卡号是: "<<x<<"    请牢记!!";
    B[t].cardnumber=x;
 B[t].password=y;
 B[t].balance=z; t++;
    cout<<"\n    操作成功,谢谢使用!!\n    按任意键+enter或者0返回:  ";
}

void CreditCard::newcard2()   //信用卡新开帐户
{
 unsigned long x,y,y1,y2; int k=1;
    double z; 
 x=5496987613+(5+q)*t;
Paw:   do
 {
  cout<<"    ------------新开信用卡帐户--------------------\n";
  cout<<"\n    请输入一个6位数字组成的密码:";
  cin>>y1;
     if(y1<99999||y1>1000000)
   {
    
    cout<<"\n☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆";
 cout<<"           -------------------------------------------------"<<endl;
 cout<<"           ||                                               ||"<<endl;
 cout<<"           ||                                               ||"<<endl;
 cout<<"           ||                   Wrong!!!                    ||"<<endl;
 cout<<"           ||                                               ||"<<endl;
 cout<<"           ||                输入无效的密码!!!              ||"<<endl;
 cout<<"           ||                                               ||"<<endl;
 cout<<"           ||                请重新设定                     ||"<<endl;
 cout<<"           ||                                               ||"<<endl;
 cout<<"           ||                                               ||"<<endl;
 cout<<"           --------------------------------------------------"<<endl;
 cout<<"☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆\n\n";
    goto Paw;
   }
        cout<<"    请再次输入密码:";
        cin>>y2;
        if(y1==y2) {y=y1;k=1;}
        else
  {  cout<<"    两次输入的密码不相同,请再次输入。\n";k=0;}
 } while(k==0);
 cout<<"    请输入开户金额: ";cin>>z;
    cout<<"    请存入现金\n    处理中,请稍后………………\n"<<"    您新开的卡号是: "<<x<<"    请牢记!!";
    C[q].cardnumber=x;
 C[q].password=y;
 C[q].balance=z;  q++;
    cout<<"\n    操作成功,谢谢使用!!按任意键+enter或者0返回:  ";
 
}

void Fzhi(unsigned long x,unsigned long y,double z)     //信用卡的赋值函数1
{ C[q].cardnumber=x;
   C[q].password=y;
   C[q].balance=z; }

void Fzhi2(unsigned long x,unsigned long y,double z)    //存折的赋值函数
{ B[t].cardnumber=x;
   B[t].password=y;
   B[t].balance=z; }

 

unsigned long BankCard::changepw(unsigned long x)            //修改密码
{   int k;
 unsigned long m,y,y1,y2;
lab7:cout<<"    ------------修改密码--------------------\n";
 cout<<"    请输入旧密码:"; cin>>m;
 if(m==x)
 {
Pawc:  do  {
   cout<<"\n    请输入一个6位数字组成的新密码:";
   cin>>y1;
        if(y1<99999||y1>1000000)
   {
    
    cout<<"\n☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆";
 cout<<"           -------------------------------------------------"<<endl;
 cout<<"           ||                                               ||"<<endl;
 cout<<"           ||                                               ||"<<endl;
 cout<<"           ||                   Wrong!!!                    ||"<<endl;
 cout<<"           ||                                               ||"<<endl;
 cout<<"           ||                输入无效的密码!!!              ||"<<endl;
 cout<<"           ||                                               ||"<<endl;
 cout<<"           ||                请重新设定                     ||"<<endl;
 cout<<"           ||                                               ||"<<endl;
 cout<<"           ||                                               ||"<<endl;
 cout<<"           --------------------------------------------------"<<endl;
 cout<<"☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆\n\n";
    goto Pawc;
   }
        cout<<"    请再次输入新密码:";
        cin>>y2;
        if(y1==y2) {y=y1;k=1;}
        else
  {  cout<<"    两次输入的密码不相同,请再次输入。\n";k=0;}
     } while(k==0);
 }else {cout<<"    输入密码错误,请重试。\n";goto lab7;}
    cout<<"\n    操作成功,谢谢使用!!按任意键+enter或者0返回:  ";
 return y;}

 

void BankCard::dele(int x,unsigned long y,double z)        //删除存折用户
{ int k=x;unsigned long m;
// unsigned long m,y,y1,y2;
lab8:cout<<"    ------------删除存折用户--------------------\n";
 cout<<"    请输入密码:";
    cin>>m;
 if(m==y)
 {  if(z==0)
  { for(k=x;k<t;k++){ B[x]=B[x+1];} t--;h=0;
  cout<<"\n    删除成功,谢谢使用!!按任意键+enter或者0返回:  ";
  }
  else
  {      h=1;
  cout<<"    对不起,您的余额为"<<z<<"元,请取出后再进行销户操作!按任意键+enter或者0返回:";}
 }
  else {cout<<"    输入密码错误,请重试。\n";goto lab8;}
}

void CreditCard::dele2(int x,unsigned long y,double z)        //删除信用卡用户
{
 int k=x;unsigned long m;
lab8:cout<<"    ------------删除信用卡用户--------------------\n";
 cout<<"    请输入密码:";
    cin>>m;
 if(m==y)
 {  if(z==0) { for(k=x;k<q;k++){ C[x]=C[x+1];} t--;h=0;
  cout<<"\n    删除成功,谢谢使用!!按任意键+enter返回:  ";
  }
  else if(z<0) {h=1; cout<<"    对不起,您的余额为"<<z<<"元,请还清透支额款后再进行销户操作!按任意键+enter或者0返回:";}
  else {h=1;cout<<"    对不起,您的余额为"<<z<<"元,请取出后再进行销户操作!按任意键+enter或者0返回:";}
 }else {cout<<"    输入密码错误,请重试。\n";goto lab8;}
}
main()
{  
 char p,a,b;  char c;
 int n=0;
    Fzhi(200502306,123456,1000);q++;      //原有2个信用卡用户
    Fzhi(200502307,123456,100);q++;   
    Fzhi2(200502308,222222,300);t++;          //原有8个存折用户
 Fzhi2(200502309,111111,400);t++;
 Fzhi2(200502310,333333,500);t++;
 Fzhi2(200502311,111111,600);t++;
 Fzhi2(200502312,111111,700);t++;
 Fzhi2(200502313,111111,800);t++;
 Fzhi2(200502314,111111,900);t++;
 Fzhi2(200502317,111111,2000);t++;


      lab3: face(n);
      cin>>a;switch(a)
     {case'A': case'a':                                //存折操作
     {    lab1: show2();  cin>>b;
                switch (b)
       { case'1':                   //新开账户
          {
         B[t].newcard(); t++;  cin>>p;
           if(p) {goto lab1;}
          }
                  case'2':                      //已有帐户
       {
                 if(t<=0)
        {cout<<"    没有数据,请新建帐户!!\n";system ("cls");goto lab1;}
                      else
        {
                       CreditCard temp;                                           //进入操作
                                   lab6: cout<<"    请输入您的帐号:";cin>>temp.cardnumber;
                       cout<<"    请输入您的密码:";cin>>temp.password;
                                   for(int i=1;i<=t;i++)
           {
           if(B[i].password==temp.password && B[i].cardnumber==temp.cardnumber)
           {
                                       system ("cls");
                                       loop:show3();
                           cin>>c;
                        switch(c)
            {   case '1': {B[i].findbalance();                      //查询余额
                    cin>>p; if(p){system ("cls");goto loop;}}
                            case '2': {B[i].getmoney();                        //取款
              cin>>p;if(p){system ("cls");goto loop;}}
                            case '3': {B[i].inmoney();                        //存款
              cout<<"    您的余额是: "<<B[i].balance<<endl;           
              cout<<"    谢谢使用!!按任意键+enter或者0返回:  ";
              cin>>p;
              if(p){system ("cls");goto loop;}}
                            case '4':{B[i].password=B[i].changepw(B[i].password);      //修改密码
              cin>>p;if(p){system ("cls");goto loop;}}
             case '0':
              {system ("cls");goto lab1;  }  //返回上一层菜单
             case'5':
              {B[i].dele(i,B[i].password,B[i].balance) ;   //删除用户
              cin>>p;
              if(p&&h==0){system ("cls");goto lab1;}
              else {system ("cls");goto loop;}
              }  
             default: {cout<<"\n\n   选择错误,请重新选择:\n";system ("cls");goto loop;}
            }
           }
           }cout<<"    帐号或密码错误,请重新填写。";goto lab6;
        }
        }
          case'0':case'c':system ("cls");goto lab3;
       default: cout<<"\n\n   选择错误,请重新选择:\n";system ("cls");goto lab1;                           //退回上一级菜单
       }
     }
   case'B':                                               //信用卡操作
   case'b':
    { 
          char b;
              lab4: show2(); cin>>b;
          switch (b)
        {  case'1':                            //新开帐户
          {
         C[t].newcard2(); t++;
                                   cin>>p;
           if(p)  goto lab4;
          }
                  case'2':                         //已有帐户
        {
                 if(q<=0)
        {cout<<"    没有数据,请新建帐户!!\n";system ("cls");goto lab4;}
                      else
        {
                       CreditCard temp;                                           //进入操作
                                   lab9: cout<<"    请输入您的帐号:";
           cin>>temp.cardnumber;
                       cout<<"    请输入您的密码:";cin>>temp.password;
                                   for(int i=1;i<=q;i++)
           {
           if(C[i].password==temp.password && C[i].cardnumber==temp.cardnumber)
           {
                                       system ("cls");
                                       lab5:show3();
                           cin>>c;
                        switch(c)
            {   
      case '1':
       {C[i].findbalance2();                      //查询余额
                    cin>>p; if(p){system ("cls");goto lab5;}}
                           
      case '2':
       {C[i].getmoney2();                        //取款
              cin>>p;if(p){system ("cls");goto lab5;}}
                           
       case '3':
        {C[i].inmoney();                        //存款
              cout<<"    您的余额是: "<<C[i].balance+OD<<"\n    其中可取款额为: "<<OD*CD+C[i].balance<<endl;           
              cout<<"    谢谢使用!!按任意键+enter或者0返回:  ";
              cin>>p;
              if(p){system ("cls");goto lab5;}}
                            case '4':
        {C[i].password=C[i].changepw(C[i].password);      //修改密码
              cin>>p;if(p){system ("cls");goto lab5;}}
              case '5':
      {C[i].dele2(i,C[i].password,C[i].balance) ;   //删除用户
              cin>>p;if(p&&h==0){system ("cls");goto lab4;}
              else {system ("cls");goto lab5;}}  
             case '0':
     {system ("cls");goto lab4;  }                               //返回上一层菜单
             default: {cout<<"\n\n   选择错误,请重新选择:\n";system ("cls");goto lab5;}
            }
           }
           }cout<<"    帐号或密码错误,请重新填写。";goto lab9;
      }
        }
   case'0': system ("cls");goto lab3;                          //返回上一层菜单
            default: cout<<"\n\n   选择错误,请重新选择:\n";system ("cls");goto lab4;
    }


    }
 case'0':
 cout<<"确定要退出系统吗?y/n."<<endl;
 {
  char choose;
  cin>>choose;
  switch(choose)
  {
  case 'y':case'Y':
     exit(0);
  case'n':case'N':
   goto lab3;
  }
 }

default: cout<<"\n\n   选择错误,请重新选择:\n";system ("cls");goto lab3; }return 0;
}