储蓄综合业务平台(代码)

原创 2013年12月26日 19:48:02

#include <iostream> #include <cstdio> #include <cstdlib> #include <iomanip> #include <conio.h> #include <string.h>//strcmp,strcpy,strlen #include <fstream> using namespace std; struct Account {     long accNum;//卡号     char Name[9];//用户名     char pass[7];//密码     double balance;//余额     char identity[19];//身份证号     char state[6];//状态(正常,挂失,冻结,销户) }; //银行中最大的账户数量 #define MAXaccNumBER 2000 //银行卡的开号初始值 #define INITNUMBER 1001; //银行中所有卡 Account array[MAXaccNumBER]; //银行中银行卡数量 int size=0; void Hello();//欢迎界面 void login();//工作人员登录 void Mean();//主菜单 int searchAcc(long accNum);//寻找卡 void Inpass(char[]);//输入密码 long autoCreament();//卡状态 void Int_identity(char iden[19]);//输入身份证 void Yan_pass(int );//密码验证 void Acc_Yan(int number);//账户验证 void Yan_exchange(int number1,int number2);//转账验证 void Yan_dong(int number);//冻结验证 void Acc_Inferr(int number);//卡信息 int Yan_identify(char g[19]);//身份证验证 void Yan_gaimi(int );//验证改密 void Yan_gaimii(int );//验证改密次数 //功能 void Acc_Open();//开户= void Acc_Delete();//销户= void Acc_Inmoney();//存款= void Acc_Outmoney();//取款= void Acc_Infer();//查询= void Acc_exchange();//转账= void Acc_dong();//冻结= void Acc_Ralese();//解冻= void Acc_Gpass();//修改密码= void Exit();//退出= void Find_pass();//找回密码 int main() {     Hello();//欢迎界面     login();//工作人员登录     return 0; } //欢迎界面 void Hello() {     cout<<"                           +--------------------------+"<<endl;     cout<<"                           +欢迎来到储蓄综合业务平台!+"<<endl;     cout<<"                           +--------------------------+"<<endl; } //工作人员登录 void login() {     char name[9],pass[7];     cout<<"请输入工作人员姓名:";     cin>>name;     cout<<endl;     if(strcmp(name,"玲玲")==0)     {         cout<<"请输入密码(三次机会):";         cin>>pass;         cout<<endl;         if(strcmp(pass,"123456")==0)         {             cout<<"登陆成功!"<<endl;             cout<<endl;             cout<<"请按任意键到主菜单:";             cout<<endl;             fflush(stdin);             getchar();             Mean();//主菜单         }         else         {             static int n=0;             ++n;             if(n==2)             {                 cout<<"三次机会已用完! 号已被封!"<<endl;                 Exit();             }             else             {                 cout<<"登录失败!请重新登录!"<<endl;                 cout<<endl;                 login();             }         }     }     else     {         cout<<"无效工作人员姓名!请重新登录!"<<endl;         cout<<endl;         login();     } } //主菜单 void Mean() {     int n;     cout<<"                                     +--------------------------+"<<endl;     cout<<"                                     +  1.开户    |   2.销户    +"<<endl;     cout<<"                                     +  3.存款    |   4.取款    +"<<endl;     cout<<"                                     +  5.查询    |   6.转账    +"<<endl;     cout<<"                                     +  7.改密    |   8.冻结    +"<<endl;     cout<<"                                     +  9.解冻    |  10.退出    +"<<endl;     cout<<"                                     + 11.寻回密码|             +"<<endl;     cout<<"                                     +--------------------------+"<<endl;     cout<<"请选择业务序号:";     fflush(stdin);     cin>>n;     cout<<endl;     switch (n)     {     case 1:         Acc_Open();         break;     case 2:         Acc_Delete();         break;     case 3:         Acc_Inmoney();         break;     case 4:         Acc_Outmoney();         break;     case 5:         Acc_Infer();         break;     case 6:         Acc_exchange();         break;     case 7:         Acc_Gpass();         break;     case 8:         Acc_dong();         break;     case 9:         Acc_Ralese();         break;     case 10:         Exit();         break;     case 11:         Find_pass();         break;     default :         cout<<"选择有误!请重新输入!"<<endl;         cout<<endl;         Mean();     } } //开户 void Acc_Open() {     cout<<"请输入姓名:";     cin>>array[size].Name;     cout<<endl;     if(strlen(array[size].Name)>9)     {         cout<<"超出最高长度!"<<endl;         cout<<endl;         cout<<"请按任意键返回!";         fflush(stdin);         getchar();         cout<<endl;         Mean();     }     cout<<"请输入身份证号(18位):";     Int_identity(array[size].identity);     cout<<endl;     Yan_identify(array[size].identity);//身份证     char passs[7]= {0};     cout<<"请输入密码:";     Inpass(array[size].pass);//调用输入密码函数     fflush(stdin);     getchar();     cout<<endl;     cout<<"请再次输入密码:";     Inpass(passs);     fflush(stdin);     getchar();     cout<<endl;     if (strcmp(passs,array[size].pass)==0)     {         cout<<"密码设置成功!"<<endl;         cout<<endl;         cout<<"请存入金额:";         cin>>array[size].balance;         cout<<endl;         if(array[size].balance<=0)         {             cout<<"输入有误!请按任意键返回!";             fflush(stdin);             getchar();             cout<<endl;             Mean();         }         strcpy(array[size].state,"正常");         array[size].accNum=autoCreament();         size++;         cout<<"开户成功!"<<endl;         cout<<endl;         cout<<"您的信息为:"<<endl;         cout<<endl;         Acc_Inferr(autoCreament()-1);         cout<<"请按任意键返回主菜单:";         fflush(stdin);         getchar();         cout<<endl;         Mean();//主菜单     }     else     {         cout<<"密码两次不一致!请重新开户!"<<endl;         cout<<endl;         Acc_Open();     } } //身份证验证 int Yan_identify(char g[]) {     if(strlen(g)!=18)     {         cout<<"输入位数有误!请正确输入!";         Int_identity(array[size].identity);         Yan_identify(g);         cout<<endl;     }     else     {         return g[19];     } } //查询卡号信息 void Acc_Infer() {     cout<<"请输入卡号:";     int number;     cin>>number;     cout<<endl;     Acc_Inferr(number);     cout<<"请按任意键返回主菜单:";     fflush(stdin);     getchar();     cout<<endl;     Mean();//主菜单 } //卡讯息 void Acc_Inferr(int number) {     Account acc;     acc=array[searchAcc(number)];     if(searchAcc(number)==-1)//卡号有误     {         cout<<"卡号不存在,请重新选择您要办理的业务!"<<endl;         Mean();     }     else     {         cout<<"+--------------------------------------------------------------------------------------------------------+"<<endl;         cout<<"+"<<setiosflags(ios::left)<<setw(20)<<"卡号"<<"|"<<setiosflags(ios::left)<<setw(20)<<"身份证号"<<"|"<<setiosflags(ios::left)<<setw(20)<<"用户名"<<"|"<<setiosflags(ios::left)<<setw(20)<<"金额"<<"|"<<setw(20)<<"状态"<<"+"<<endl;         cout<<"+--------------------------------------------------------------------------------------------------------+"<<endl;         cout<<"+"<<setiosflags(ios::left)<<setw(20)<< number<<"|"<<setiosflags(ios::left)<<setw(20)<<acc.identity<<"|"<<setiosflags(ios::left)<<setw(20)<<acc.Name<<"|"<<setiosflags(ios::left)<<setw(20)<<setiosflags(ios::fixed)<<setprecision(2)<<acc.balance<<"|"<<setiosflags(ios::left)<<setw(20)<<acc.state<<"+"<<endl;         cout<<"+--------------------------------------------------------------------------------------------------------+"<<endl;     }     cout<<endl; } //输入密码 void Inpass(char pas[7]) {     char ch;     int i=0;     while(i<6)     {         ch=getch();         if(ch<='9'&&ch>='0')         {             putch('*');             pas[i]=ch;             i++;         }     } } //销户 void Acc_Delete() {     int number;     Account acc;     cout<<"请输入卡号:";     cin>>number;     cout<<endl;     acc=array[searchAcc(number)];     if(searchAcc(number)==-1)//卡号有误     {         cout<<"卡号不存在,请重新选择您要办理的业务!"<<endl;         cout<<endl;         Mean();     }     else     {         char password[7]= {0};         cout<<"请输入密码(三次机会):";         Inpass(password);         fflush(stdin);         getchar();         if (strcmp(acc.pass,password)==0)         {             cout<<"请按任意键表示确认:";             fflush(stdin);             getchar();             cout<<endl;             cout<<"销户成功!"<<endl;             cout<<endl;             strcpy(array[searchAcc(number)].state,"销户");             cout<<"您的信息为:"<<endl;             cout<<endl;             Acc_Inferr(number);             cout<<"请按任意键返回主菜单:";             array[searchAcc(number)].balance=0;             fflush(stdin);             getchar();             cout<<endl;             Mean();         }     } } //存款 void Acc_Inmoney() {     int accNum;     double money;     cout<<"请输入卡号:";     cin>>accNum;     cout<<endl;     Acc_Yan(accNum);     cout<<"请输入存款金额:";     cin>>money;     cout<<endl;     if(money<=0)     {         cout<<"输入有误!请按任意键返回!"<<endl;         fflush(stdin);         getchar();         cout<<endl;         Mean();     }     array[searchAcc(accNum)].balance+=money;//找到了该卡号所对应的卡     cout<<"您的余额为:"<<setiosflags(ios::fixed)<<setprecision(2)<<array[searchAcc(accNum)].balance<<"元"<<endl;     cout<<endl;     cout<<"请按任意键退回主菜单"<<endl;     cout<<endl;     fflush(stdin);     getchar();     Mean(); } //取款 void Acc_Outmoney() {     int number;     cout<<"请输入卡号:";     cin>>number;     cout<<endl;     Acc_Yan(number);     Yan_pass(number); } //取款密码验证 void Yan_pass(int number) {     char passs[7]= {0};     double money;     static int o=0;     Account acc;     acc=array[searchAcc(number)];     cout<<"请输入密码(三次机会):";     Inpass(passs);     fflush(stdin);     getchar();     cout<<endl;     if (strcmp(passs,acc.pass)==0)     {         cout<<"请输入取款金额:";         cin>>money;         cout<<endl;         if(money<=0)         {             cout<<"输入有误!请按任意键返回!"<<endl;             fflush(stdin);             getchar();             cout<<endl;             Mean();         }         if(acc.balance<money)         {             cout<<"您的余额已不足!"<<'\n'<<"请按任意键返回主菜单";             fflush(stdin);             getchar();             cout<<endl;             Mean();         }         else         {             array[searchAcc(number)].balance=array[searchAcc(number)].balance-money;             cout<<"您的余额为:"<<setiosflags(ios::fixed)<<setprecision(2)<<array[searchAcc(number)].balance<<"元"<<endl;             cout<<endl;             cout<<"请按任意键退回主菜单"<<endl;             fflush(stdin);             getchar();             cout<<endl;             Mean();         }     }     else     {         if(o==2)         {             cout<<"三次机会用完,账号已被冻结!"<<endl;             cout<<endl;             int pos;             pos=searchAcc(number);             strcpy(array[pos].state,"冻结");             cout<<"请按任意键返回主菜单:";             fflush(stdin);             getchar();             cout<<endl;             Mean();         }         else         {             cout<<endl;             cout<<"密码错误!"<<endl;             cout<<endl;             ++o;             Yan_pass(number);         }     } } //冻结 void Acc_dong() {     int number;     cout<<"请输入卡号:";     cin>>number;     cout<<endl;     Acc_Yan(number);     Yan_dong(number);     cout<<endl;     cout<<"请按任意键确定冻结:"<<endl;     fflush(stdin);     getchar();     cout<<"冻结成功!"<<endl;     cout<<endl;     strcpy(array[searchAcc(number)].state,"冻结");     cout<<"您的信息为:"<<endl;     cout<<endl;     Acc_Inferr(number);     cout<<"请按任意键返回主菜单:";     fflush(stdin);     getchar();     cout<<endl;     Mean(); } //解冻 void Acc_Ralese() {     int number;     cout<<"请输入卡号:";     cin>>number;     cout<<endl;     Yan_dong(number);     if(strcmp(array[searchAcc(number)].state,"冻结")!=0)     {         cout<<"该账户未冻结,无需解冻!"<<endl;         cout<<endl;         cout<<"请按任意键返回主菜单:";         cout<<endl;         fflush(stdin);         getchar();         Mean();     }     cout<<"解冻成功!"<<endl;     cout<<endl;     strcpy(array[searchAcc(number)].state,"正常");     cout<<"您的信息为:"<<endl;     cout<<endl;     Acc_Inferr(number);     cout<<"请按任意键返回主菜单:";     cout<<endl;     fflush(stdin);     getchar();     Mean(); } //冻结验证 void Yan_dong(int number) {     static int o=0;     cout<<"请输入密码(三次机会):";     char passs[7];     Account acc;     acc=array[searchAcc(number)];     Inpass(passs);     fflush(stdin);     getchar();     if (strcmp(passs,acc.pass)!=0)     {         if(o==2)         {             cout<<"三次机会用完,账号已被冻结!"<<endl;             cout<<endl;             int pos;             pos=searchAcc(number);             strcpy(array[pos].state,"冻结");             cout<<"请按任意键返回主菜单:";             cout<<endl;             fflush(stdin);             getchar();             Mean();         }         else         {             cout<<endl;             cout<<"密码错误!"<<endl;             cout<<endl;             ++o;             Yan_dong(number);         }     } } //退出 void Exit() {     cout<<"已退出!"<<endl;     cout<<endl;     exit(0); } //寻找卡 int searchAcc(long accNum) {     int i,pos=-1;     for(i=0; i<size; i++)     {         if(array[i].accNum==accNum)//找到了这张卡         {             pos=i;             break;         }     }     return pos;//返回下标 } //卡状态 long autoCreament() {     if(size==0)     {         return INITNUMBER;     }     else     {         return array[size-1].accNum+1;     } } //输入身份证 void Int_identity(char iden[19]) {     cin>>iden; } //转账 void Acc_exchange() {     int number1,number2,n;     cout<<"请输入您的卡号:";     cin>>number1;     cout<<endl;     Acc_Yan(number1);     cout<<"请输入对方的卡号:";     cin>>number2;     cout<<endl;     if(number1==number2)     {         cout<<"不能给自己转账!按任意键返回主菜单:";         cout<<endl;         Mean();     }     else     {         Acc_Yan(number2);         cout<<"该用户信息为:"<<endl;         cout<<endl;         Acc_Inferr(number2);         cout<<"确定转账请按1,返回主菜单请按2:";         cin>>n;         cout<<endl;         switch(n)         {         case 1:             Yan_exchange(number1,number2);             break;         case 2:             Mean();             break;         default :             cout<<"选择错误!"<<'\n'<<"按任意键返回主菜单:";             fflush(stdin);             getchar();             cout<<endl;             Mean();         }     } } //转账验证 void Yan_exchange(int number1,int number2) {     char passs[7];     double money;     static int o=0;     Account acc1,acc2;     acc1=array[searchAcc(number1)];     acc2=array[searchAcc(number2)];     cout<<"请输入密码(三次机会):";     Inpass(passs);     fflush(stdin);     getchar();     cout<<endl;     if (strcmp(passs,acc1.pass)==0)     {         cout<<"请输入转账金额:";         cin>>money;         cout<<endl;         if(money<=0)         {             cout<<"输入有误!请按任意键返回!"<<endl;             fflush(stdin);             getchar();             cout<<endl;             Mean();         }         if(acc1.balance<money)         {             cout<<"您的余额已不足!"<<'\n'<<"请按任意键返回主菜单";             fflush(stdin);             getchar();             cout<<endl;             Mean();         }         else         {             array[searchAcc(number1)].balance=acc1.balance-money;             array[searchAcc(number2)].balance=acc2.balance+money;             cout<<"转账成功!"<<endl;             cout<<endl;             cout<<"您的余额为:"<<setiosflags(ios::fixed)<<setprecision(2)<<acc1.balance<<"元"<<endl;             cout<<endl;             cout<<"请按任意键退回主菜单"<<endl;             fflush(stdin);             getchar();             cout<<endl;             Mean();         }     }     else     {         if(o==2)         {             cout<<"三次机会用完,账号已被冻结!"<<endl;             cout<<endl;             strcpy(array[searchAcc(number1)].state,"冻结");             cout<<"请按任意键返回主菜单:";             fflush(stdin);             getchar();             cout<<endl;             Mean();         }         else         {             cout<<endl;             cout<<"密码错误!"<<endl;             cout<<endl;             ++o;             Yan_exchange(number1,number2);         }     } } //账户信息验证 void Acc_Yan(int number) {     int pos;     pos=searchAcc(number);     if(pos==-1)//卡号有误     {         cout<<"卡号不存在!请重新选择您要办理的业务!"<<endl;         cout<<endl;         Mean();     }     else if(strcmp(array[pos].state,"冻结")==0)     {         cout<<"账户已被冻结!"<<'\n'<<"请重新选择您要办理的业务!"<<endl;         cout<<endl;         Mean();     }     else if(strcmp(array[pos].state,"销户")==0)     {         cout<<"卡号不存在!请重新选择您要办理的业务!"<<endl;         cout<<endl;         Mean();     } } //改密 void Acc_Gpass() {     int num;     cout<<"请输入卡号:";     cin>>num;     cout<<endl;     Acc_Yan(num);     Yan_gaimi(num); } //验证改密 void Yan_gaimi(int num) {     cout<<"请输入密码(三次机会):";     char pass[7];     Inpass(pass);     if(strcmp(array[searchAcc(num)].pass,pass)==0)     {         fflush(stdin);         getchar();         cout<<endl;         cout<<"登陆成功!"<<endl;         cout<<endl;         Yan_gaimii(num);     }     else     {         static int o=0;         if(o==2)         {             cout<<"三次机会用完,账号已被冻结!"<<endl;             cout<<endl;             int pos;             pos=searchAcc(num);             strcpy(array[pos].state,"冻结");             cout<<"请按任意键返回主菜单:";             fflush(stdin);             getchar();             cout<<endl;             Mean();         }         else         {             cout<<endl;             cout<<"密码错误!"<<endl;             cout<<endl;             ++o;             Yan_gaimi(num);         }     } } //验证改密次数 void Yan_gaimii(int num) {     char passs[7]= {0},passss[7]= {0};     static int l=0;     if(l==2)     {         cout<<"三次机会已用完!改密失败!"<<'\n'<<"请按任意键返回主菜单:";         fflush(stdin);         getchar();         cout<<endl;         Mean();     }     else     {         cout<<"请输入新密码:";         Inpass(passs);         fflush(stdin);         getchar();         cout<<endl;         cout<<"请再输入一次新密码:";         Inpass(passss);         fflush(stdin);         getchar();         cout<<endl;         if(strcmp(passs,passss)!=0)         {             cout<<"两次输入密码不一致!"<<endl;             cout<<endl;             l++;             Yan_gaimii(num);         }         else         {             cout<<"改密成功!"<<endl;             cout<<endl;             strcpy(array[searchAcc(num)].pass,passs);             cout<<"请按任意键返回主菜单:";             fflush(stdin);             getchar();             cout<<endl;             Mean();         }     } } //找回密码 void Find_pass() {     char identity[19]= {0};     int number;     cout<<"请输入卡号:";     cin>>number;     cout<<endl;     Acc_Yan(number);     cout<<"请输入身份证号:";     Int_identity(identity);     cout<<endl;     cout<<identity;

    if(strcmp(array[searchAcc(number)].identity,identity)==0)     {         cout<<"身份验证成功!"<<endl;         cout<<endl;         cout<<"您的密码为:"<<array[searchAcc(number)].pass<<endl;         cout<<endl;         cout<<"请按任意键返回主菜单:";         fflush(stdin);         getchar();         cout<<endl;         Mean();     }     else     {         cout<<"身份验证失败!按任意键返回主菜单:";         fflush(stdin);         getchar();         cout<<endl;         Mean();     } }

 

 

2013.12.26

相关文章推荐

2012年上半年项目实训“银行储蓄综合业务平台”C++版

项目名称: 银行储蓄综合业务平台 编写语言: 面向对象的C++语言 --先建一个空项目 --添加一个头文件名为“Record.h” 代码为: #ifndef HEADER_RECORD ...

技术支持课--项目实训--储蓄综合业务平台(第一期)--开户功能实现--c语言编写

实验目的:制作储蓄综合业务平台 实验内容:实现储蓄的开户功能 * 程序头部注释开始 * 程序的版权和版本声明部分 * Copyright (c) 2011, 烟台大学计算机学院学生  * A...

2011年下半年项目“银行储蓄综合业务平台”C语言版

项目名称: 银行储蓄综合业务平台 编写语言: 面向对象的C语言 代码: --先建一个空项目   --添加一个头文件名称为“Bank.h” 头文件代码为: ...

储蓄业务平台_C语言代码

  • 2009年04月26日 10:32
  • 42KB
  • 下载

银行综合储蓄业务系统,水平为学了一年C语言

银行综合储蓄业务系统 #include #include int acccunt = 0; char name[10],pw[10]; struct user   //定义结构体 {...

大一下学期项目设计—综合储蓄平台—Node类

简述实验:创建节点 头文件: #ifndef HEADER_NODE//预处理命令,防止文件被多次引用。 #define HEADER_NODE//预处理命令,防止文件被多次引用。 #incl...

C语言——储蓄平台业务

  • 2009年04月13日 10:18
  • 42KB
  • 下载

大一下学期项目设计—综合储蓄平台—Record类

简述实验:实现基本用户信息的存储 头文件: #ifndef HEADER_RECORD//预处理命令,防止文件被多次引用。 #define HEADER_RECORD//预处理命令,防止文件被多...

银行储蓄业务管理系统代码

  • 2012年05月24日 11:05
  • 2KB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:储蓄综合业务平台(代码)
举报原因:
原因补充:

(最多只允许输入30个字)