C语言ATM程序模拟.docx
- 文档编号:4375100
- 上传时间:2022-12-01
- 格式:DOCX
- 页数:23
- 大小:203.58KB
C语言ATM程序模拟.docx
《C语言ATM程序模拟.docx》由会员分享,可在线阅读,更多相关《C语言ATM程序模拟.docx(23页珍藏版)》请在冰豆网上搜索。
C语言ATM程序模拟
一、课题要求
1、当输入给定的卡号和密码(初始卡号和密码为123456)时,系统能登录ATM柜员机系统。
2、查询余额:
初始余额为10000元。
3、ATM取款:
每次取款金额为100的倍数,总额不超过5000元,支取金额不允许透支。
4、ATM存款:
不能出现负存款。
5、修改密码:
新密码长度不小于6位,不允许出现6位完全相同的情况,只有旧密码正确,新密码符合要求,且两次输入相同的情况下才可以成功修改密码。
二、代码
#include"stdafx.h"
#include"stdio.h"
#include"windows.h"
#include"stdlib.h"
#include"conio.h"
voidgotoxy(intx,inty);//光标位置函数
voidenter_ATM();//账号输入函数
voidinput_code();//密码输入函数
voidcaozuo();//基本操作界面
voidqukuan();//取款函数
voidsuccess();//操作成功函数
voiddelay();//延时函数
voidyu_e();//余额查询函数
voidcunkuan();//存款函数
voidpanduan(longintz);//判断取款是否合法函数
voidexit();//退出界面函数
voidmima();//密码修改
voidzhuangyi();
longintCODE=123456,YU_E=10000;
//=========================主函数========================//
main()
{
enter_ATM();
caozuo();
}
//======================================================//
//==================================柜台机账号输入函数=======================================//
voidenter_ATM()
{
system("cls");
printf("********************************\n");
printf("**\n");
printf("*欢迎使用ATM柜台机*\n");
printf("*请输入卡号*\n");
printf("**\n");
printf("*取消确定*\n");
printf("**\n");
printf("********************************\n");
longintuser;
gotoxy(14,4);
scanf("%d",&user);
while(user!
=123456)
{
system("cls");
printf("********************************\n");
printf("**\n");
printf("*账户不存在,请从新输入*\n");
printf("**\n");
printf("**\n");
printf("*取消确定*\n");
printf("**\n");
printf("********************************\n");
gotoxy(13,3);
scanf("%d",&user);
}
input_code();
}
//==========================================================================================//
//=======================================密码输入函数========================================//
voidinput_code()
{
longintcode;
inttemp=3,time;
system("cls");
printf("********************************\n");
printf("**\n");
printf("*请输入密码*\n");
printf("**\n");
printf("**\n");
printf("*取消确定*\n");
printf("**\n");
printf("********************************\n");
gotoxy(14,3);
scanf("%d",&code);
while(code!
=CODE)
{
temp--;
if(temp==0)
{
for(time=5;time>0;time--)
{
system("cls");
printf("********************************\n");
printf("**\n");
printf("*您已经3次输入密码*\n");
printf("*系统将退出操作*\n");
printf("**\n");
printf("*");
printf("%d",time);
printf("*\n");
printf("**\n");
printf("********************************\n");
delay();
}
enter_ATM();
}
system("cls");
printf("********************************\n");
printf("**\n");
printf("*密码错误,请重新输入*\n");
printf("*您还有");
printf("%d",temp);
printf("次机会*\n");
printf("**\n");
printf("*取消确定*\n");
printf("**\n");
printf("********************************\n");
gotoxy(14,4);
scanf("%d",&code);
}
caozuo();
}
//=====================================================================================//
//============================================主操作界面函数========================================//
voidcaozuo()
{
system("cls");
printf("********************************\n");
printf("*请选择一下业务*\n");
printf("*1.修改密码*\n");
printf("*2.查询余额*\n");
printf("*3.取款*\n");
printf("*4.实时存款*\n");
printf("*5.退出*\n");
printf("********************************\n");
switch(getch())
{
case'1':
mima();break;
case'2':
yu_e();break;
case'3':
qukuan();break;
case'4':
cunkuan();break;
case'5':
exit();break;
default:
printf("error\n");
}
}
//==================================================================================================//
//==============================密码修改函数==============================//
voidmima()
{
longintmm1,mm2,mm3;
chartemp;
system("cls");
printf("********************************\n");
printf("**\n");
printf("*旧密码:
*\n");
printf("**\n");
printf("*新密码:
*\n");
printf("*确认新密码:
*\n");
printf("**\n");
printf("********************************\n");
gotoxy(15,2);
scanf("%d",&mm1);
gotoxy(15,4);
scanf("%d",&mm2);
gotoxy(15,5);
scanf("%d",&mm3);
if(mm1!
=CODE)
{
system("cls");
printf("********************************\n");
printf("**\n");
printf("*旧密码错误*\n");
printf("**\n");
printf("*请重新输入!
*\n");
printf("**\n");
printf("**\n");
printf("********************************\n");
delay();
delay();
zhuangyi();
}
if(mm2!
=mm3)
{
system("cls");
printf("********************************\n");
printf("**\n");
printf("*确认密码不一致*\n");
printf("**\n");
printf("*请重新输入!
*\n");
printf("**\n");
printf("**\n");
printf("********************************\n");
delay();
delay();
zhuangyi();
}
if(mm2<100000)
{
system("cls");
printf("********************************\n");
printf("**\n");
printf("*密码必须大于或等于6位数*\n");
printf("**\n");
printf("*请重新输入!
*\n");
printf("**\n");
printf("**\n");
printf("********************************\n");
delay();
delay();
zhuangyi();
}
temp=mm2%111111;
if(temp==0)
{
system("cls");
printf("********************************\n");
printf("**\n");
printf("*密码过于简单*\n");
printf("**\n");
printf("*请重新输入!
*\n");
printf("**\n");
printf("**\n");
printf("********************************\n");
delay();
delay();
zhuangyi();
}
CODE=mm2;
system("cls");
printf("********************************\n");
printf("**\n");
printf("*操作成功*\n");
printf("**\n");
printf("*1.返回2.退出*\n");
printf("**\n");
printf("**\n");
printf("********************************\n");
switch(getch())
{
case'1':
caozuo();break;
case'2':
exit();break;
}
}
//======================================================================//
//==========================余额查询函数============================//
voidyu_e()
{
system("cls");
printf("********************************\n");
printf("**\n");
printf("**\n");
printf("*系统正在查询*\n");
printf("*请稍候...*\n");
printf("**\n");
printf("**\n");
printf("********************************\n");
delay();
delay();
system("cls");
printf("********************************\n");
printf("**\n");
printf("*您的余额为*\n");
printf("**\n");
printf("");
printf("%d",YU_E);
printf("\n**\n");
printf("*1.返回2.退出*\n");
printf("********************************\n");
switch(getch())
{
case'1':
caozuo();break;
case'2':
exit();break;
}
}
//==================================================================//
//===================================取款函数====================================//
voidqukuan()
{
longinttemp;
system("cls");
printf("********************************\n");
printf("*请选择您要取款的金额*\n");
printf("*1.1002.200*\n");
printf("*3.5004.800*\n");
printf("*5.10006.其它*\n");
printf("**\n");
printf("*7.返回8.退出*\n");
printf("********************************\n");
switch(getch())
{
case'1':
panduan(100);break;
case'2':
panduan(200);break;
case'3':
panduan(500);break;
case'4':
panduan(800);break;
case'5':
panduan(1000);break;
case'6':
system("cls");
printf("********************************\n");
printf("**\n");
printf("*请输入您要取款的金额*\n");
printf("**\n");
printf("**\n");
printf("**\n");
printf("**\n");
printf("********************************\n");
gotoxy(14,4);
scanf("%d",&temp);
panduan(temp);break;
case'7':
caozuo();break;
case'8':
exit();break;
}
}
//================================================================================//
//======================================判断取款是否合法函数==================================//
voidpanduan(longintz)
{
intbeishu;
if(z>YU_E)
{
system("cls");
printf("********************************\n");
printf("**\n");
printf("*余额不足!
*\n");
printf("*请重新操作*\n");
printf("**\n");
printf("*1.返回2.退出*\n");
printf("**\n");
printf("********************************\n");
switch(getch())
{
case'1':
qukuan();
case'2':
exit();
}
}
beishu=z%100;
if(beishu!
=0)
{
system("cls");
delay();
printf("********************************\n");
printf("**\n");
printf("*本ATM机只支持100的人民币*\n");
printf("*请重新操作*\n");
printf("**\n");
printf("*1.返回2.退出*\n");
printf("**\n");
printf("********************************\n");
switch(getch())
{
case'1':
qukuan();
case'2':
exit();
}
}
if(z==5000||z>5000)
{
system("cls");
printf("********************************\n");
printf("**\n");
printf("*每次取款不能超过5000元*\n");
printf("*请重新操作*\n");
printf("**\n");
printf("*1.返回2.退出*\n");
printf("**\n");
printf("********************************\n");
switch(getch())
{
case'1':
qukuan();
case'2':
exit();
}
}
YU_E=YU_E-z;
success();
}
//==========================================================================================//
//==============================================存款函数=============================================//
voidcunkuan()
{
longinttemp;
system("cls");
printf("********************************\n");
printf("**\n");
printf("*请放入人民币*\n");
printf("**\n");
printf("*取消确定*\n");
printf("**\n");
printf("**\n");
printf("********************************\n");
gotoxy(14,3);
scanf("%d",&temp);
while(temp<0)
{
system("cls");
printf("********************************\n");
printf("**\n");
printf("*非法存款*\n");
printf("*请重新放入人民币*\n");
printf("**\n");
printf("*取消确定*\n");
printf("**\n");
printf("********************************\n");
gotoxy(14,4);
scanf("%d",&temp);
}
YU_E=YU_E+temp;
success();
}
//=================================================================================================//
//===================================光标位置函数=========================================//
voidgotoxy(intx,inty)
{
COORDcoord;
coord.X=x;
coord.Y=y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 语言 ATM 程序 模拟