关于模拟ATM机模拟程序
运行出现了一个错误,希望大家看一下:#include<stdio.h>
#include<stdlib.h>
void main()
{
char key,CMmoney;
int password,password1=123,i=1,a=1000;
while(1)
{
do
{
system("cls");
printf("*************************\n");
printf("* please select key: *\n");
printf("* 1.password *\n");
printf("* 2.get money *\n");
printf("* 3.return *\n");
printf("*************************\n");
key=getchar();
}
while(key!='1'&&key!='2'&&key!='3');
switch(key)
{
case'1':
system("cls");
do
{
i++;
printf(" please input password ");
scanf("%d",&password);
if(password1!=password)
{
if(i>3)
{
printf("wrong!press any key to exit...");
getchar();
exit(0);
}
else
puts("wrong ,try again");
}
}
while(password1!=password&&i<=3);
printf("ok!press any key to continue...");
getchar();
case'2':
do
{
system("cls");
if(password1!=password)
{
printf("please logging in,press any key to continue...");
getchar();
break;
}
else
{
system("cls");
printf("*************************\n");
printf("* please select *\n");
printf("* 1.100$ *\n");
printf("* 2.200$ *\n");
printf("* 3.300$ *\n");
printf("* 4.return *\n");
printf("*************************\n");
CMmoney=getchar();
}
while(CMmoney!='1'&&CMmoney!='2'&&CMmoney!='3');
switch(CMmoney)
{
case'1':
system("cls");
a=a-100;
printf("*************************\n");
printf("* your credit money is $100,thank you! *\n");
printf("* the balance is $%d. *\n",a);
printf("* press any key to return... *\n");
printf("*************************\n");
CMmoney=getchar();
break;
case'2':
system("cls");
a=a-100;
printf("*************************\n");
printf("* your credit money is $200,thank you! *\n");
printf("* the balance is $%d. *\n",a);
printf("* press any key to return... *\n");
printf("*************************\n");
CMmoney=getchar();
break;
case'3':
system("cls");
a=a-100;
printf("*************************\n");
printf("* your credit money is $300,thank you! *\n");
printf("* the balance is $%d. *\n",a);
printf("* press any key to return... *\n");
printf("*************************\n");
CMmoney=getchar();
break;
case'4':
break;
}
break;
case'3':
printf("*************************\n");
printf("* thank you for your using! *\n");
printf("* goodbye! *\n",a);
printf("*************************\n");
getchar();
break;
}
break;
}
}