ATM机

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 <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;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值