C语言ATM自动存取款机全套代码
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
C语言ATM自动存取款机全套代码
#include
#include
#include
#include
#include
#define N 6
char b[N]={'8','8','8','8','8','8'};//存放密码
int money=5000;
int securitytime=3;
void Login();
void JieMian();
void SaveMoney();
void GetMoney();
void Query();
void Return();
//密码验证函数,验证成功返回1,否则返回0
void Login()
{
char a[20],ch; //用户登录密码,用以验证
int i=0,n=1,k;
printf("\n\t\t欢迎使用ICBC ATM自动存取款机\n"); printf("\n请输入密码:");
for(n=1;n<=5;n++)
{while((a[i]=getch())!=13)
{ i=i+1;
printf("*");//将用户输入的密码以*显示
}
for(k=0;k<6;k++)
if(a[k]!=b[k]) break;
if (k==6)
{printf("\n密码正确,请继续!!\n");
JieMian(); }
else
//printf("\n密码错误,请重新输入:\n");
printf("\n密码错误,您还有%d次机会,请重新输入:\n",5-n);
}
printf("\n您已经输入5次错误,您的卡将被没收,请去相关网点办理!\n");
exit(1);
}
// 界面设计
void JieMian()
{
int SelectKey;
//system("cls");//清屏幕函数
while(1)
{puts("\n= = = = = = = = = = = = = = = =");
puts("| 请选择相应功能: |");
puts("| 1. 修改密码PassWord |");
puts("| 2. 查询功能Query |");
puts("| 3. 取款功能Get Money |");
puts("| 4. 存款功能Save Money | ");
puts("| 5. 转帐功能Trans Money | ");
puts("| 6. 退出功能Return | ");
puts("\n= = = = = = = = = = = = = = = = ");
printf("\n请选择功能:");
scanf("%d",&SelectKey);
switch(SelectKey)
{ case 1:printf("\n修改密码功能\n");//PassWord();break;
case 2:printf("\n查询功能\n");Query();break;
case 3:printf("\n取款功能\n");GetMoney();break;
case 4:printf("\n存款功能\n");SaveMoney();break;
case 5:printf("\n转帐功能\n");//Trans();break;
case 6:printf("\n退出功能\n");Return();break;
}
}}
/*Query查询功能*/
void Query()
{
system("cls");
puts("================================== ==");
printf("| Your Query balance is $%ld |\n",money);
puts("| Press any key to return... |");
puts("================================== ==");
return;
}
/*GetMoney取钱功能*/
void GetMoney()
{char GetMoney;
char kahao[20];
long y;
//输入待转入的相关信息
//卡号,姓名
do
{
puts("=================================");
puts("| Please select GetMoney: |");
puts("| 1. $100 |");
puts("| 2. $200 |");
puts("| 3. other |");
puts("| 4. Return |");
puts("=================================");
GetMoney = getch();
}while(GetMoney!='1'&&GetMoney!='2'&&GetMoney!='3' && GetMoney!='4');
switch(GetMoney)
{case '1':
syst
em("cls");
if(money>100)
{puts("================================== =========");
puts("| Your GetMoney is $100,Thank you! |");
puts("| Press any key to return... |");
puts("==================================
=========");
money=money-100;
printf("\n您的余额为%d",money);}
else printf("\n您的余额不足!");
getch();
break;
case '2':
system("cls");
if(money>200)
{puts("================================== ======");
puts("| Your GetMoney is $200,Thank you! |");
puts("| Press any key to return... |");
puts("================================== ======");
money=money-200;
printf("\n 您的余额为%d",money);}
else printf("\n您的余额不足!");
getch();
break;
case '3':
system("cls");
printf("please get some money:");
scanf("%ld",&y);
if(money>y)
{money=money-y;
printf("\n您的余额为%d",money);}
else
{printf("\n您的余额不足!");
printf("\n您的余额为%d",money);}
getch();
break;
case '4': break;
}return;
}
/*SaveMoney存钱功能*/
void SaveMoney()
{ char SaveMoney;
long y;
do
{system("cls");
puts("================================== ========");
puts("| Please select Save Money: |");
puts("| 1. $100 |");
puts("| 2. $500 |");
puts("| 3. $1000 |");
puts("| 4. other |");
puts("| 5. Return |");
puts("================================== ========");
SaveMoney = getch();
}
while(SaveMoney!='1'&&SaveMoney!='2'&& SaveMoney!='3'&&SaveMoney!='4'&&SaveMoney!='5');
switch(SaveMoney)
{ case '1':
{
{system("cls");
puts("================================== =========");
puts("| Your save money is $100,Thank you! |");
puts("| Press any key to return... |");
puts("================================== ========");}
money=money+100;
printf("\n您的余额为%d",money);
getch();}
break;
case '2':
{system("cls");
puts("================================== ============");
puts("| Your Save Money is $500,Thank you! |");
puts("| Press any key to return... |");
puts("================================== ============");
money=money+500;
printf("\n您的余
额为%d",money);
getch();}
break;
case '3':
{system("cls");
puts("==================================
==========");
puts("| Your Save Money is $1000,Thank you! |");
puts("| Press any key to return... |");
puts("================================== ==========");
money=money+1000;
printf("\n您的余额为%d",money);
getch();}
break;
case '4':
{system("cls");
puts("================================== ===========");
puts("| Your Save some Money,Thank you! |");
puts("| Press any key to return... |");
puts("================================== ===========");
puts("please save some money:");
scanf("%ld",&y);
if(y%100!=0)
printf("该存款机只能处理整百的操作,请核查!!");
else
{
money=money+y;
printf("\n您的余额为%d",money);}
getch();}
break;
case '5':
break; }return;
}
/*Return,退出功能*/
void Return()
{
system("cls");
puts("================================== ==");
puts("| Thank you for your using! |");
puts("| RETURN! |");
puts("================================== ==");
exit(1);
}
//主函数
int main()
{
Login();
}
上一页下一页。