ATM机
#include <stdio.h>
#include <stdlib.h>
struct bank_card
{
long int card_num[19];
int card_password;
float money;
};
int main()
{
struct bank_card person;
int x, y, funtion, draw, deposi;
scanf_s("%ld %d %f", &person.card_num, &person.card_password, &person.money);//inserting bank card
printf("Please input your bank card's password:\n");
while (1)
{
scanf_s("%d", &x);
if (x == person.card_password)
{
printf("Welcom!\n");
break;
}
else printf("Your password is incorrect and please re-enter your password:\n");
}
while (1)
{
scanf_s("%d", &funtion);
if (funtion == 1)
printf("Your have %f yuan\n", person.money);
else if (funtion == 2)
{
y = 3;
printf("Please input the amount to be taken:\n");
while (1)
{
scanf_s("%d", &draw);
if (draw <= person.money)
{
printf("A successful deal\n");
person.money = person.money - draw;
printf("Your bank card have %f yuan\n", person.money);
break;
}
else
{
printf("Lack of balance\nYou only have %d times\n",y-1);
y--;
}
if (y == 0||draw==0) break;
}
}
else if (funtion == 3)
{
y = 0;
printf("Please input the amount deposited:\n");
while (1)
{
printf("Please fold the nots neatly and put them in the deposi box.Please put less than 100 nots\n");
scanf_s("%d", &deposi);
if (deposi % 100 == 0)
{
printf("A successful deal\n");
person.money = person.money + deposi;
printf("Your bank card have %f yuan\n", person.money);
break;
}
else
{
printf("Please put again\nYou only have %d times\n", y - 1);
y--;
}
if (y == 0||deposi==0) break;
}
}
else if (funtion == 0)
{
printf("Thank you for your use\n");
break;
}
}
system("pause");
return 0;
}
#include <stdlib.h>
struct bank_card
{
long int card_num[19];
int card_password;
float money;
};
int main()
{
struct bank_card person;
int x, y, funtion, draw, deposi;
scanf_s("%ld %d %f", &person.card_num, &person.card_password, &person.money);//inserting bank card
printf("Please input your bank card's password:\n");
while (1)
{
scanf_s("%d", &x);
if (x == person.card_password)
{
printf("Welcom!\n");
break;
}
else printf("Your password is incorrect and please re-enter your password:\n");
}
while (1)
{
scanf_s("%d", &funtion);
if (funtion == 1)
printf("Your have %f yuan\n", person.money);
else if (funtion == 2)
{
y = 3;
printf("Please input the amount to be taken:\n");
while (1)
{
scanf_s("%d", &draw);
if (draw <= person.money)
{
printf("A successful deal\n");
person.money = person.money - draw;
printf("Your bank card have %f yuan\n", person.money);
break;
}
else
{
printf("Lack of balance\nYou only have %d times\n",y-1);
y--;
}
if (y == 0||draw==0) break;
}
}
else if (funtion == 3)
{
y = 0;
printf("Please input the amount deposited:\n");
while (1)
{
printf("Please fold the nots neatly and put them in the deposi box.Please put less than 100 nots\n");
scanf_s("%d", &deposi);
if (deposi % 100 == 0)
{
printf("A successful deal\n");
person.money = person.money + deposi;
printf("Your bank card have %f yuan\n", person.money);
break;
}
else
{
printf("Please put again\nYou only have %d times\n", y - 1);
y--;
}
if (y == 0||deposi==0) break;
}
}
else if (funtion == 0)
{
printf("Thank you for your use\n");
break;
}
}
system("pause");
return 0;
}
#include <stdio.h>
#include <stdlib.h>
struct bank_card
{
long int card_num[19];
int card_password;
float money;
};
int main()
{
struct bank_card person;
int x, y, funtion, draw, deposi;
scanf_s("%ld %d %f", &person.card_num, &person.card_password, &person.money);//inserting bank card
printf("Please input your bank card's password:\n");
while (1)
{
scanf_s("%d", &x);
if (x == person.card_password)
{
printf("Welcom!\n");
break;
}
else printf("Your password is incorrect and please re-enter your password:\n");
}
while (1)
{
scanf_s("%d", &funtion);
if (funtion == 1)
printf("Your have %f yuan\n", person.money);
else if (funtion == 2)
{
y = 3;
printf("Please input the amount to be taken:\n");
while (1)
{
scanf_s("%d", &draw);
if (draw <= person.money)
{
printf("A successful deal\n");
person.money = person.money - draw;
printf("Your bank card have %f yuan\n", person.money);
break;
}
else
{
printf("Lack of balance\nYou only have %d times\n",y-1);
y--;
}
if (y == 0||draw==0) break;
}
}
else if (funtion == 3)
{
y = 0;
printf("Please input the amount deposited:\n");
while (1)
{
printf("Please fold the nots neatly and put them in the deposi box.Please put less than 100 nots\n");
scanf_s("%d", &deposi);
if (deposi % 100 == 0)
{
printf("A successful deal\n");
person.money = person.money + deposi;
printf("Your bank card have %f yuan\n", person.money);
break;
}
else
{
printf("Please put again\nYou only have %d times\n", y - 1);
y--;
}
if (y == 0||deposi==0) break;
}
}
else if (funtion == 0)
{
printf("Thank you for your use\n");
break;
}
}
system("pause");
return 0;
}