码迷,mamicode.com
首页 > 编程语言 > 详细

c语言实现ATM机

时间:2016-04-04 06:56:12      阅读:419      评论:0      收藏:0      [点我收藏+]

标签:include   c语言   return   密码   atm机   

#include<stdio.h>

#include<stdlib.h>


void chaxun(a3)

{

int b;

b = a3;

printf("您的余额:%d\n", b);

}


int qukuan(int a3)

{

int a=0, b=0;

printf("请输入要取的金额:\n");

scanf("%d", &a);

b = a3 - a;

if (b < 0)

{

printf("您的余额不足\n");

}

else

{


printf("请拿好你的%d元现金\n",a);

a3 = a3 - a;

}

return a3;


}


int gaimi(int a2)

{

int b, d, c = 1, e = 1;

while (e)

{

printf("请输入您的原密码\n");

scanf("%d", &d);

if (a2 == d)

{

e = 0;

}

else

{

e = 1;

printf("密码错误,请重新输入\n");

}

}

while (c)

{

printf("请输入您的新密码\n");

scanf("%d", &a2);

printf("请确认您的新密码\n");

scanf("%d", &b);

if (a2 == b)

{

printf("密码修改成功\n");

c = 0;

}

else

{

c = 1;

printf("俩次输入不一致,请重新修改\n");


}

}

return a2;

}


void quka()

{

printf("请收好您的卡片\n");

printf("谢谢,再见\n");

}


int cunkuan(int a3)

{

int k = 0;

printf("请输入您要存的金额\n");

scanf("%d", &k);

a3 = a3 + k;

printf("您的总金额为%d\n",a3);


return a3;

}


int main()

{

int b = 1, c, k, l, q = 1;

int a1 = 123456, a2 = 123456, a3 = 1000;

printf("欢迎使用atm机\n");

while (q)

{

printf("请输入您的帐号\n");

scanf("%d", &k);

printf("请输入密码\n");

scanf("%d", &l);

if (a1 == k&&a2 == l)

{

printf("您的账户余额为%d", a3);

q = 0;

}

else

{

printf("您的密码错误,请重新输入\n");

q = 1;

}

}

do{

printf("请选择\n");

printf("1查询\n");

printf("2取款\n");

printf("3修改密码\n");

printf("4取卡\n");

printf("5存款\n");

scanf("%d", &c);

switch (c)

{

case 1:

chaxun(a3);

break;

case 2:

a3 = qukuan(a3);

break;

case 3:

a2 = gaimi(a2);

break;

case 4:

quka();

break;

case 5:

cunkuan(a3);

break;

default:

break;

}

} while (c != 4);


return;

}


c语言实现ATM机

标签:include   c语言   return   密码   atm机   

原文地址:http://10942013.blog.51cto.com/10932013/1759974

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!