您的位置:首页 > 编程语言 > C语言/C++

C语言ATM机代码,简单版。

2014-08-23 16:41 176 查看
#include <stdio.h>

void main()
{
int i,j;
int code=0,flag=0;
int choice1=0,choice2=0,choice3=0;
int RMB=100000,WB=100000;
int cash1=0,cash2=0;
char instruct='n';

printf("************************************************************\n");
printf("*             *\n");
printf("*                  *\n");
printf("* 欢迎使用 怪精 ATM取款机                *\n");
printf("*                  *\n");
printf("* 监制: rain version number:1.0.1            *\n");
printf("*                                       *\n");
printf("*                                      *\n");
printf("************************************************************\n");

printf("请键入您的密码:\n");    /*密码为9527*/

for(i=0;i<3;i++)
{
scanf("%d",&code);
system("cls");
if(code==9527)
{
break;
}
if(code!=9527)
{
printf("密码有误!请重新输入:\n");
flag+=1;
}
}
if(flag==3)
{
printf("密码错误超限,请回去面壁思过,再见!");
return;
}

while(instruct=='N'|| instruct=='n' )
{

if(code==9527)
{
printf("请选择您所需服务!\n");
printf("1.查询余额 2.取款 3.退出");
scanf("%d",&choice1);
system("cls");
switch(choice1)
{
case 1:printf("1.人民币 2.外汇");
scanf("%d",&choice2);
system("cls");

switch(choice2)
{
case 1:printf("您的人民币账户余额:¥%d\n",RMB);
break;

case 2:printf("您的外币账户余额:$%d\n",WB);
break;
}
break;

case 2:printf("1.人民币 2.外币");
scanf("%d",&choice3);
system("cls");

switch(choice3)
{
case 1:printf("请输入取款金额:\n");
scanf("%d",&cash1);

RMB=RMB-cash1;
printf("您的账户余额为:¥%d\n",RMB);
break;

case 2:printf("请输入取款金额:\n");
scanf("%d",&cash2);

WB=WB-cash2;
printf("您的账户余额为:$%d\n",WB);
break;
}
break;
case 3:
break;

}
printf("是否退出程序<y表示是,n表示否>:");
scanf("%s",&instruct);
}

}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: