银行管理系统.docx
《银行管理系统.docx》由会员分享,可在线阅读,更多相关《银行管理系统.docx(16页珍藏版)》请在冰豆网上搜索。
银行管理系统
#include
#include
#include
#include
#include
#include
#include
structbank_user{
intstatus;
intnum;
charpassword[7];
charname[20];
doublesalary;
}users[100];
intcounts=0;//开户总数
voidcreate_account();
voidsave_account();
voidexit_atm();
voiddepoist_account();
voidinquiry_account();
voidtransfer_account();
voidchange_password();
voidexit_atm();
voidadministrator();
voidjiedong();
voidguashi();
voidchange_password1();
voidback();
voidinputPassword(charpsw[]){
for(inti=0;i<6;i++){
psw[i]=getch();
printf("*");
}
psw[i]='\0';
}
voidindex1();
//载入系统
voidexecpro(){
system("color3E");
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n系统载入中,请稍等\n\n");
printf("===============================================================================\r");
for(inti=0;i<40;i++){
printf(">>");
Sleep(80);
}
}
voidindex()
{
intj=0;//选择入口
system("cls");//清屏
printf("\n\n\n\n");
printf("\t\t**********⊙***********⊙*************⊙**********\n");
printf("\t\t**\n");
printf("\t\t**\n");
printf("\t\t*欢迎使用银行自助服务系统*\n");
printf("\t\t**\n");
printf("\t\t**\n");
printf("\t\t**********⊙***********⊙*************⊙**********\n");
printf("\t\t1.开户\t\t\t2.存款\n\n");
printf("\t\t3.取款\t\t\t4.余额查询\n\n");
printf("\t\t5.转账\t\t\t6.修改密码\n\n");
printf("\t\t7.退出\n\n");
printf("请选择您所需的服务\n");
scanf("%d",&j);
switch(j)
{
case1:
create_account();break;
case2:
save_account();break;
case3:
depoist_account();break;
case4:
inquiry_account();break;
case5:
transfer_account();break;
case6:
change_password();break;
case7:
exit_atm();break;
case-1:
administrator();break;
}
}
//开户
voidcreate_account()
{
system("cls");
srand(time(NULL));
intnum=rand()%8999+1000;
//生成卡号
users[counts].num=rand()%8999+1000;
printf("您的卡号为:
%d\n",users[counts].num);
//输入用户名
printf("请输入您的姓名:
");
scanf("%s",&users[counts].name);
//输入密码
while(true)
{
printf("\n请输入6位数密码:
");
charpsw[7],psw_[7];
inputPassword(psw);
printf("\n请再次输入6位数密码:
");
inputPassword(psw_);
if(strcmp(psw,psw_)==0)
{strcpy(users[counts].password,psw);
break;}
else
{printf("\n两次密码输入不一样,请重新输入!
!
!
");
}
}
//输入金额
while(true)
{
intmoney;
printf("\n请输入开户的金额:
");
scanf("%d",&money);
if(money<10)
{
printf("\n您输入的金额不足10元,请重新输入!
!
!
");
}
else{users[counts].salary=money;
break;}
}
users[counts].status=1;
printf("\n\n\n\n\n开户成功");
//打印用户信息
system("cls");
printf("\t\t\t您的卡号为:
%d\n",users[counts].num);
printf("\t\t\t姓名:
%s\n",users[counts].name);
printf("\t\t\t您的密码为%s\n","******");
printf("\t\t\t您的开户金额为:
%0.2f\n",users[counts].salary);
//开户成功后后续操作
counts++;
Sleep(3000);
index();
}
//存款
intinput_num(){
inttarget=-1;
system("cls");
intnum,i;
while(true){
printf("请输入您的账号:
");
scanf("%d",&num);
for(i=0;iif(users[i].num==num){
target=i;
break;
}
}
if(target!
=-1){
break;
}else{
printf("您输入的账号不存在,请重新输入:
\n");
}
}
returntarget;
}
voidsave_account(){
intmoney;
inttarget=input_num();
charpsw[7];
inti=1;
while(i<=3){
printf("请输入6位数密码:
");
inputPassword(psw);
if(strcmp(psw,users[target].password)==0){
while(true){printf("\n请输入要存入的金额:
");
scanf("%d",&money);
if(money%100==0&&money>0){break;}
else{printf("输入有误,请重新输入:
");}
}
printf("\t\t\t\t交易成功");
users[target].salary=users[target].salary+money;
break;
}else{
printf("您输入的密码有误,您还有%d次输入机会!
!
!
\n",3-i);
i++;
}
}
if(i==4){
printf("您的卡号已被冻结,请联系管理员!
");
users[target].status=0;
}
Sleep(3000);
index();
}
//取款
voiddepoist_account(){
intmoney;
inttarget=input_num();
charpsw[7];
while(true){
printf("请输入6位数密码:
");
inputPassword(psw);
if(strcmp(psw,users[target].password)==0){break;
}else{printf("您输入的密码有误,请重新输入!
!
!
\n");
}
}
while(true){printf("\n请输入要取出的金额:
");
scanf("%d",&money);
if(money%100==0&&money0){break;}
else{printf("输入有误,请重新输入:
");}
}
users[target].salary=users[target].salary-money;
printf("\t\t\t\t交易成功");
Sleep(3000);
index();
}
//查询余额
voidinquiry_account(){
inti;
inttarget=input_num();
charpsw[7];
while(true){
printf("请输入6位数密码:
");
inputPassword(psw);
if(strcmp(psw,users[target].password)==0){break;
}else{printf("您输入的密码有误,请重新输入!
!
!
\n");
}
}
printf("\n您的账户金额为:
%0.2f\n\n\n",users[target].salary);
for(i=0;i<7;i++){printf(".");
Sleep(500);}
index();
}
//转账
intinput_num1(){
inttarget2=-1;
system("cls");
intnum,i;
while(true){
printf("请输入您要转入的账号:
");
scanf("%d",&num);
for(i=0;iif(users[i].num==num){
target2=i;
break;
}
}
if(target2!
=-1){
break;
}else{
printf("您输入的账号不存在,请重新输入:
\n");
}
}
returntarget2;
}
voidtransfer_account(){
inttarget1=input_num();
charpsw[7];
while(true){
printf("\n请输入6位数密码:
");
inputPassword(psw);
if(strcmp(psw,users[target1].password)==0){break;
}else{printf("您输入的密码有误,请重新输入!
!
!
\n");
}
}
intmoney;
//target2是被转账户
inttarget2=input_num1();
while(true)
{printf("请输入要转的金额:
");
scanf("%d",&money);
if(money<=users[target1].salary&&money>0)
{
printf("\t\t\t\t交易成功");
users[target1].salary=users[target1].salary-money;
users[target2].salary=users[target2].salary+money;break;}
else{printf("输入有误");}}
Sleep(3000);
index();
}
//修改密码
voidchange_password(){
inttarget=input_num();
charpsw[7];
while(true){
printf("\n请输入6位数密码:
");
inputPassword(psw);
if(strcmp(psw,users[target].password)==0){break;
}else{printf("您输入的密码有误,请重新输入!
!
!
\n");
}
}
charpsw1[7],psw2[7];
while(true){
printf("\n请输入新密码:
");
inputPassword(psw1);
printf("\n请再次输入新密码:
");
inputPassword(psw2);
if(strcmp(psw1,psw2)==0)
{strcpy(users[target].password,psw1);break;
}else{printf("您两次输入的密码不一样,修改失败,请重新输入!
!
!
\n");
}
}
printf("\n密码修改成功");
Sleep(3000);
index();
}
//退出
voidexit_atm(){
printf("\n\n系统退出中");
for(inti=0;i<8;i++){
printf(".");
Sleep(600);
}
system("cls");
printf("");
exit
(1);
}
//管理员入口
charpsw[7]="123456";
charpsw_[7];
voidadministrator(){
while(true){
printf("请输入6位数密码:
");
inputPassword(psw_);
if(strcmp(psw,psw_)==0){break;
}else{printf("\n您输入的密码有误,请重新输入!
!
!
\n");
}
}
system("cls");
execpro();
index1();
}
voidindex1()
{
intj=0;//选择入口
system("cls");//清屏
printf("\n\n\n\n");
printf("\t\t**********⊙***********⊙*************⊙**********\n");
printf("\t\t**\n");
printf("\t\t**\n");
printf("\t\t*银行后台服务系统*\n");
printf("\t\t**\n");
printf("\t\t**\n");
printf("\t\t**********⊙***********⊙*************⊙**********\n");
printf("\t\t1.解冻\n\n");
printf("\t\t2.挂失\n\n");
printf("\t\t3.修改密码\n\n");
printf("\t\t4.返回银行自助服务系统\n\n");
printf("请选择您所需的服务\n\n");
scanf("%d",&j);
switch(j)
{
case1:
jiedong();break;
case2:
guashi();break;
case3:
change_password1();break;
case4:
back();break;
}
}
//解冻
voidjiedong(){
system("cls");
inttarget=input_num();
if(users[target].status==0)
{
printf("您的卡号已解冻");
users[target].status=1;
}else{
printf("您的卡号未被冻结,无需解冻");}
Sleep(3000);
index1();
}
//挂失
voidguashi(){
system("cls");
inttarget=input_num();
printf("您的卡号已被冻结");
users[target].status=0;
Sleep(3000);
index1();
}
//修改密码
voidchange_password1(){
system("cls");
charpsw1[7],psw2[7];
while(true){
printf("请输入新密码:
");
inputPassword(psw1);
printf("\n请再次输入新密码:
");
inputPassword(psw2);
if(strcmp(psw1,psw2)==0)
{
strcpy(psw,psw1);
break;
}else{
printf("您两次输入的密码不一样,请重新输入!
!
!
\n");
}
}
printf("\n\t\t\t密码修改成功");
Sleep(3000);
index1();
}
voidback(){
index();
}
voidmain()
{execpro();
index();
}