c语言模拟atm机程序

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

#include"stdio.h"
#include"string.h"
#include"stdlib.h"
#include"conio.h"
void mainmenu(int);
int languagemenu();
void query(float,int);
float deposit(float,int);
float withdraw(float,int);
int main()
{
int exit=0,language=languagemenu();
float money=(float)1000;
char in;
while(!exit)
{
mainmenu(language);
in=getch();
switch(in)
{
case '1':query(money,language);break;
case '2':money=deposit(money,language);break;
case '3':money=withdraw(money,language);break;
case '4':return 0;
}
}
return 0;
}
int languagemenu()
{
char input;
system("cls");
printf("========================\n");
printf("| 1. 中文 |\n");
printf("| 2. English |\n");
printf("| 3. 退出\\Exit |\n");
printf("========================\n");
input=getch();
while(1)
{
switch(input)
{
case'1':return 0;
case'2':return 1;
case'3':exit(0);
default:input=getch();
}
}
}
void mainmenu(int is_lan)
{
system("cls");
if(is_lan)
{
printf("========================\n");
printf("| 1. Query |\n");
printf("| 2. Deposit |\n");
printf("| 3. Withdraw |\n");
printf("| 4. Exit |\n");
printf("========================\n");
}
else
{
printf("========================\n");
printf("| 1. 查询 |\n");
printf("| 2. 存钱 |\n");
printf("| 3. 取钱 |\n");
printf("| 4. 退出 |\n");
printf("========================\n");
}
}
void query(float money,int is_lan)
{
system("cls");
if(is_lan)
{
printf("========================\n");
printf("rest ¥ %.2f\n",money);
printf("press any key to continue\n");
printf("========================\n");
}
else
{
printf("========================\n");
printf("此账户有 ¥ %.2f\n",money);
printf("按任意继续\n");
printf("========================\n");
}
getch();
}

float deposit(float money,int is_lan)
{
float input;
system("cls");
if(is_lan)
{
printf("========================\n");
printf("the number of money: ¥");
scanf("%f%*c",&input);
printf("press any key to continue\n");
printf("========================\n");
}
else
{
printf("========================\n");
printf("输入您要取钱的数目 ¥");
scanf("%f%*c",&input);
printf("按任意键继续\n");
printf("========================\n");
}
getch();
return money+input;
}
float withdraw(float money,int is_lan)
{
float input;
if(is_lan)
{
while(1)
{
system("cls");
printf("========================\n");
printf("the number of money: ¥");
scanf("%f%*c",&input);
if(inputbreak;
else
{
printf("error,press any key to continue!\n");
getch();
}
}
printf("press any key to continue\n");
printf("========================\n");
}
else
{
while(1)
{
system("cls");
printf("=====

===================\n");
printf("输入您要取钱的数目: ¥");
scanf("%f%*c",&input);
if(inputbreak;
else
{
printf("余额不足,按任意键后重新输入!\n");
getch();
}
}
printf("按任意键继续\n");
printf("========================\n");
}
getch();
return money-input;
}

相关文档
最新文档