#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(input<money)
break;
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(input<money)
break;
else
{
printf("余额不足,按任意键后重新输入!\n");
getch();
}
}
printf("按任意键继续\n");
printf("========================\n");
}
getch();
return money-input;
}