文件名称:C++ 银行系统
文件大小:27KB
文件格式:DOC
更新时间:2010-09-15 09:58:28
C++ 银行系统
#include
#include
double qu(double dbYe)
{
double dbQu=0.0;
int nA=0,nB=0;
while(nB==0)
{
printf("请输入取款金额:");
scanf("%lf",&dbQu);
if(dbYe
printf("余额不足,重新输入取款金额按1,退出请按0");
scanf("%d",&nA);
printf("\n");
if(nA==1)
{
continue;
}else
{
break;
}
}else
{
dbYe=dbYe-dbQu;
printf("正在准备现金,请稍等……\n");
printf("操作成功,请取走现金\n");
break;
}
}
return dbYe;
}
double cun(double dbCun)
{
printf("请输入存款金额:");
scanf("%lf",&dbCun);
printf("正在存入现金请稍等\n");
printf("操作成功\n");
return dbCun;
}
double cha(double dbYe)
{
char cA=0;
printf("您帐户的余额为%.2lf元\n",dbYe);
return dbYe;
}
void main()
{
int nA=1,nB=1,nXz=0;
double dbYe=100000,dbCun=0.0;
char ID[]={"thinkbank"};
char PW[20]={"tb"};
char sID[20]={"0"};
char sPW[20]={"0"};
while(nA==1)
{
printf("========================\n");
printf("==欢迎使用自助银行系统==\n");
printf("========================\n");
printf("\n\n");
printf("请输入您的帐号:\n");
scanf("%s",&sID);
printf("请输入您的密码:\n");
scanf("%s",&sPW);
if(strcmp(ID,sID) != 0 && strcmp(PW,sPW) != 0)
{
printf("您输入的帐号或密码错误,请重新输入\n");
continue;
}
nB=1;
while(nB==1)
{
printf("可执行的操作\n");
printf("1.取款\n");
printf("2.存款\n");
printf("3.查询余额\n");
printf("4.修改密码\n");
printf("5.退出\n");
printf("请选择您要进行的操作:");
scanf("%d",&nXz);
switch(nXz)
{
case 1:
{
dbYe=qu(dbYe);
break;
}
case 2:
{
dbYe=dbYe+cun(dbCun);
break;
}
case 3:
{
cha(dbYe);
break;
}
case 4:
{
break;
}
case 5:
{
nB=2;
break;
}
default:
{
printf("您的输入有误,请重新选择所要进行的操作\n");
break;
}
}
}
}
}