c语言模拟atm机答案,模拟ATM机功能(C语言)

/*

fuction:模拟ATM机存取功能

date:2014/8/20

by:zhouhaiou

*/

#include

#include

#include

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

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;

}

}

原文:http://www.cnblogs.com/zhouhaiou/p/3931102.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值