模拟ATM机功能(C语言)

/*
fuction:模拟ATM机存取功能
date:2014/8/20
by:zhouhaiou
*/

#include <stdio.h>
#include <string.h>
#include <math.h>
int money=100000;

void query();
void transf();

void welcome()//欢迎界面
{
printf("\t\t***********************************************\n");
printf("\t\t* *\n");
printf("\t\t* ---欢迎光临LOL自助银行--- *\n");
printf("\t\t* *\n");
printf("\t\t* 用户名:F10 版本14.08.20 *\n");
printf("\t\t* *\n");
printf("\t\t* 制作人:zhouhaiou *\n");
printf("\t\t* *\n");
printf("\t\t* 客服电话:95599 *\n");
printf("\t\t***********************************************\n");
printf("\n");

}


int password(char str[])//验证password
{
char ps1[]="123.";
char ps2[20]="0";
int i=1;
printf("\t\t\t\t***温馨提示***\n\t\t\t\t密码只能输入3次!\n");
printf("\n");
printf("\n");
printf("请输入你的密码:");
scanf("%s",ps2);
do
{
if(strcmp(ps1,ps2)!=0)
{
printf("\n密码错误!\n请重新输入密码:");
scanf("%s",ps2);
i++;
}
else
{
system("cls");
return 1;
break;
}

}while(i<3);
if(i>=3)
{
if(strcmp(ps1,ps2)!=0)
{
printf("你输入密码错误次数超过3次,不能使用本系统,请联系相关管理员!\n");
getch();
return 0;
}
else
{
system("cls");
return 1;
}
}

}

void menu(int num)//主菜单
{
int choice=0,money1=0,money2=0;
printf("*******请选择你需要的服务:*****\n");
printf("* *\n");
printf("* 1.查询 2.取款 *\n");
printf("* *\n");
printf("* 3.存款 4.转账 *\n");
printf("* *\n");
printf("* 5.退出 *\n");
printf("* *\n");
printf("********************************\n");
printf("\n");
scanf("%d",&choice);
while(choice!=5)
{
switch(choice)
{
case 1:system("cls");
query(choice);
system("pause");
break;
case 2:system("cls");
qukuan(money1);
system("pause");
break;
case 3: system("cls");
cunkuan(money2);
system("pause");
break;
case 4: system("cls");
transf();
system("pause");
break;
case 5: printf("退出");
break;
}
system("cls");
printf("*******请选择你需要的服务:*****\n");
printf("* *\n");
printf("* 1.查询 2.取款 *\n");
printf("* *\n");
printf("* 3.存款 4.转账 *\n");
printf("* *\n");
printf("* 5.退出 *\n");
printf("* *\n");
printf("********************************\n");
printf("\n");
scanf("%d",&choice);
}
system("cls");
printf("欢迎你的下次光临,系统正在退出.....\n");
getch();

}

void query(int num)//查询余额
{
int choice=0;
printf("1.人民币\t2.外币\n");
scanf("%d",&choice);
system("cls");
switch(choice)
{
case 1:printf("你的余额为:%d元\n",money);
break;
case 2:printf("your money:$%d\n",money);
break;
}
}

int qukuan(int num)//取款
{
int money1=0;
printf("请输入你需要取走的金额:");
scanf("%d",&money1);
do
{
if(money1>money)
{
printf("余额不足,请重新输入:");
scanf("%d",&money1);
}
else
{
system("cls");
printf("系统正在处理,请稍后.....\n");
system("pause");
system("cls");
break;
}
}while(money1<money);
printf("恭喜你成功取走%d元!\n",money1);
money=money-money1;
}

int cunkuan(int num)//存款
{
int money2=0;
printf("请输入你要存入的金额:");
scanf("%d",&money2);
system("cls");
printf("系统正在处理中,请稍候.....\n");
system("pause");
system("cls");
money=money+money2;
printf("存入%d成功!\n",money2);

}

void transf()//转账
{
printf("请见谅,此功能系统正在维护.....\n");
}

void main()
{
char psword[10];
int choice=0,flag=0;
welcome();
flag=password(psword);
if(flag==1)
{
menu(choice);
}
else
{
return;
}

}

posted @ 2014-08-23 14:48  zhouhaiou  阅读(782)  评论(0编辑  收藏  举报