2021-05-18

大一--C语言--atm

#include"stdio.h"
#include"stdlib.h"
#include"math.h"
#include"windows.h"
#include"string.h"

int a();
int b();
int c();
int d();
int e();
int f();
int g();
int h();
int i();



int main()
{
	
     
	 for(int sum=1;sum<=99999;sum++)
	 {
		 
	system("cls");
		 system("color fd");
     printf(" 欢迎使用ATM操作系统\n ");
     printf("\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\n ");
	 printf("请示入数字执行以下指令\n ");
	 printf(" 1.创建账户   2.存款\n ");
	 printf(" 3.取款       4.查询金额\n");
	 printf("  5.挂失       6.解挂\n ");
	 printf(" 7.修改密码   8.销户\n ");
	 printf(" 9.转账      a.退出\n ");

    char num = getchar();
	
	switch(num)
	{

	  	    case '1': a();	break;
			case '2': b();	break;
			case '3': c();  break;
			case '4': d();	break;
			case '5': e();  break;
			case '6': f();  break;
			case '7': g();  break;
			case '8': h();  break;
			case '9': i();  break;
			case 'a': 
				sum = 99999 ;
				break;
            default:	
			printf(" 叫你输入1—9以内的数或a,大聪明 \n");
			system("color f3");
			printf(" 叫你输入1—9以内的数或a,大聪明 \n");
			
			printf(" 叫你输入1—9以内的数或a,大聪明 \n");
				
		break;
	}

		system("pause");
	    system("cls");
	 }
	return 1;
	}




typedef struct
{
  int  username;        //用户名
  char  id_card[19];       //身份证
  int password;   //密码
  int password_2;  //确认密码
  float money;       //钱
  int situation;     // 状态  0——正常 1——挂失 2——销户
}Account;


Account leek[100];
int person = 1;
int ch=1;





int a()//开户
{
		system("pause");
	system("cls");
	system("color f2");
	printf("\t\t\t欢迎使用开户系统\t\t\t\n");
int x1;

 
  leek[person].username = 100000 + person;
  printf("Loading......\n");
  printf("\n您的用户名是: ");
  printf("%d\n",leek[person].username);
  while(1)
  {
  printf("\n请输入你的身份证号\n");
 
  scanf("%s",&leek[person].id_card);
  if(strlen(leek[person].id_card) == 18)
  {
	  break;
  }
  else
  {
  printf("身份证号为18位,请重试");
  }
  }
 while(1)
  {
     printf("\n请输入6位数密码\n");
  scanf("%d",&leek[person].password);
	  if(leek[person].password >= 100000 && leek[person].password <= 999999)
  {
     while(1)
	 {
     printf("\n请输入确认密码\n\n");
  scanf("%d",&leek[person].password_2);
  if( leek[person].password == leek[person].password_2)
  {
	  printf("\n 恭喜您,开户成功\n");
  person ++;
  leek[person].money = 0;
  leek[person].situation = 0;
  printf("\n 当前余额为0.00元\n");
  break;
  }else
  {
	  printf("\n两次密码不一致,请您重新输入\n");
  }
 }
break;
	  }
else
{
printf("密码应为6位数,请您重试");
}
	}  
  return x1;
}
	  




int b()//存钱
{
		system("pause");
	system("cls");
	system("color f3");
		printf("\n\t\t\t欢迎使用存款系统\t\t\t\n");
	int x2;
	int username1;
	printf("\n\t\t\t请输入用户名\t\t\t\n");
	scanf("%d",&username1);
    int person1;
	int password1;
	float money1;
	person1 = username1 - 100000;
if( username1 == leek[person1].username && leek[person1].situation == 0 )
{
	printf("\t\t\t\n请输入密码\t\t\t\n");
	scanf("%d",&password1);
	if( password1 == leek[person1].password  )
	{
	printf("\t\t\t\n密码正确,请输入存款金额\t\t\t\n");
        scanf("%f",&money1);
		leek[person1].money = money1 + leek[person1].money ;
		printf("\t\t\t\n存款成功,当前余额为%.2f元",leek[person1].money);
	}
	else{
	printf("\n\t\t\t 密码不正确\t\t\t\n");
	}
}else if(leek[person1].situation = 0)
{
	printf("\t\t\t\n抱歉,该同户名尚未注册\t\t\t\n");
}
else if(username1 == leek[person1].username )
{
printf("\n\t\t\t该账户异常\t\t\t\n");
}
return x2;
}




int c() //取钱
{
	int x3;
		system("pause");
	system("cls");
	system("color f4");
		printf("\n\t\t\t欢迎使用取款系统\t\t\t\n");
	
	int username1;
	printf("\n\t\t\t请输入用户名\t\t\t\n");
	scanf("%d",&username1);
    int person1;
	int password1;
	float money1;
	person1 = username1 - 100000;
if( username1 == leek[person1].username && leek[person1].situation == 0 )
{
	printf("\t\t\t\n请输入密码\t\t\t\n");
	scanf("%d",&password1);
	if( password1 == leek[person1].password  )
	{
	printf("\t\t\t\n密码正确,请输入取款金额\t\t\t\n");
        scanf("%f",&money1);
		if(money1 < leek[person1].money)
		{
		leek[person1].money =  leek[person1].money - money1 ;
		
		printf("\t\t\t\n存款成功,当前余额为%.2f元",leek[person1].money);
	}
		else("\n\t\t\t 抱歉,余额不足\t\t\t\n");
	}
	else{
	printf("\n\t\t\t 密码不正确\t\t\t\n");
	}
}else if(leek[person1].situation = 0)
{
	printf("\t\t\t\n抱歉,该同户名尚未注册\t\t\t\n");
}
else if(username1 == leek[person1].username )
{
printf("\n\t\t\t该账户异常\t\t\t\n");
}
return x3;
}




int d() //查寻余额
{
	int x4;
		system("pause");
	system("cls");
	system("color f5");
		printf("\n\t\t\t欢迎使用查询余额系统\t\t\t\n");
	
	int username1;
	printf("\n\t\t\t请输入用户名\t\t\t\n");
	scanf("%d",&username1);
    int person1;
	int password1;
	
	person1 = username1 - 100000;
if( username1 == leek[person1].username  && leek[person1].situation == 0 )
{
	printf("\t\t\t\n请输入密码\t\t\t\n");
	scanf("%d",&password1);
	if( password1 == leek[person1].password  )
	{
	printf("\t\t\t\n密码正确\t\t\t\n");
      
		printf("\t\t\t\n当前余额为%.2f元",leek[person1].money);
	}
	else{
	printf("\n\t\t\t 密码不正确\t\t\t\n");
	}
}else if(leek[person1].situation = 0)
{
	printf("\t\t\t\n抱歉,该同户名尚未注册\t\t\t\n");
}
else if(username1 == leek[person1].username )
{
printf("\n\t\t\t该账户异常\t\t\t\n");
}
return x4;
}




int e()//挂失
{
	int x5;
		system("pause");
	system("cls");
	system("color f6");
		printf("\n\t\t\t欢迎使用挂失系统\t\t\t\n");
	
	int username1;
	printf("\n\t\t\t请输入用户名\t\t\t\n");
	scanf("%d",&username1);
    int person1;
	char id_card1[19];

	person1 = username1 - 100000;
if( username1 == leek[person1].username  && leek[person1].situation == 0 )
{
	printf("\t\t\t\n请输入身份证号码\t\t\t\n");
	scanf("%s",&id_card1);
	if( id_card1[19] == leek[person1].id_card[19]  )
	{
		leek[person1].situation = 1;
	printf("\t\t\t\n挂失成功\t\t\t\n");
       
	
	}
	else{
	printf("\n\t\t\t 身份证号码不正确,挂失失败\t\t\t\n");
	}
}else if(leek[person1].situation = 0)
{
	printf("\t\t\t\n抱歉,该同户名尚未注册\t\t\t\n");
}
else if(username1 == leek[person1].username )
{
printf("\n\t\t\t该账户已挂失或销户\t\t\t\n");
}
return x5;
} 


int f()//解除挂失
{
	int x6;
	
		system("pause");
	system("cls");
	system("color f7");
		printf("\n\t\t\t欢迎使用解除挂失系统\t\t\t\n");
	
	int username1;
	printf("\n\t\t\t请输入用户名\t\t\t\n");
	scanf("%d",&username1);
    int person1;
	char id_card1[19];

	person1 = username1 - 100000;
if( username1 == leek[person1].username  && leek[person1].situation == 1 )
{
	printf("\t\t\t\n请输入身份证号码\t\t\t\n");
	scanf("%s",&id_card1);
	if( id_card1[19] == leek[person1].id_card[19]  )
	{
		leek[person1].situation = 0;
	printf("\t\t\t\n挂失成功\t\t\t\n");
       
	
	}
	else{
	printf("\n\t\t\t 身份证号码不正确,解除挂失失败\t\t\t\n");
	}
}else if(leek[person1].situation = 1)
{
	printf("\t\t\t\n抱歉,该同户名尚未注册\t\t\t\n");
}
else if(username1 == leek[person1].username )
{
printf("\n\t\t\t该账户未挂失或已销户\t\t\t\n");
}
return x6;
}






int g() //修改密码
{
int x7;
	system("pause");
	system("cls");
	system("color f8");
	printf("\t\t\t欢迎使用修改密码系统\t\t\t\n");
int username1;
	printf("\n\t\t\t请输入用户名\t\t\t\n");
	scanf("%d",&username1);
    int person1;
	int password1;
	char id_card1[19];
  
	
	if( username1 == leek[person1].username && leek[person1].situation == 0 )
{
	printf("\t\t\t\n请输入密码\t\t\t\n");
	scanf("%d",&password1);
	if( password1 == leek[person1].password  )
	{
	printf("\t\t\t\n密码正确\t\t\t\n");
      
		printf("\t\t\t\n请输入身份证号码\t\t\t\n");
	scanf("%s",&id_card1);
	if( id_card1[19] == leek[person1].id_card[19]  )
	{
	  while(1)
	  {
     printf("\n请输入6位数密码\n");
  scanf("%d",&leek[person].password);
	  if(leek[person].password >= 100000 && leek[person].password <= 999999)
  {
     while(1)
	 {
     printf("\n请输入确认密码\n\n");
  scanf("%d",&leek[person].password_2);
  if( leek[person].password == leek[person].password_2)
  {
	  printf("\n 恭喜您,修改密码成功\n");
  person ++;
  leek[person].money = 0;
  leek[person].situation = 0;
  printf("\n 当前余额为0.00元\n");
  break;
  }else
  {
	  printf("\n两次密码不一致,请您重新输入\n");
  }
 }
break;
	  }
else
{
printf("密码应为6位数,请您重试");
}
	}  
	
	}
	else{
	printf("\n\t\t\t 身份证号码不正确\t\t\t\n");
	}
	
	}else{
	printf("\n\t\t\t 密码不正确\t\t\t\n");
	}
}else if(leek[person1].situation = 0)
{
	printf("\t\t\t\n抱歉,该同户名尚未注册\t\t\t\n");
}
else if(username1 == leek[person1].username )
{

printf("\n\t\t\t该账户异常\t\t\t\n");

}

return x7;
}






int h()// 销户
{
	int x8;

	system("pause");
	system("cls");
	system("color f9");
	printf("\n\t\t\t欢迎使用销户系统\t\t\t\n");
int username1;
	printf("\n\t\t\t请输入用户名\t\t\t\n");
	scanf("%d",&username1);
    int person1;
	int password1;


	person1 = username1 - 100000;
if( username1 == leek[person1].username && leek[person1].situation == 0 )
{

	printf("\t\t\t\n请输入密码\t\t\t\n");
	scanf("%d",&password1);

	if( password1 == leek[person1].password  )
	{

		printf("\t\t\t\n当前余额为%.2f元",leek[person1].money);
        printf("\n\t\t\t取款成功,当前余额为0.00元\t\t\t\n");
        leek[person1].money = 0 ;
         leek[person1].situation = 2 ;
		 printf("\n\t\t\t销户成功,再见\1\2\1\3\2\1\t\t\t\n");

	}
	else{
	printf("\n\t\t\t 密码不正确\t\t\t\n");
	}
}else if(leek[person1].situation = 0)
{
	printf("\t\t\t\n抱歉,该同户名尚未注册\t\t\t\n");
}
else if(username1 == leek[person1].username )
{
printf("\n\t\t\t该账户已挂失\t\t\t\n");
}
return x8;
}





int i()
{
	int x9;

	system("pause");
	system("cls");
	system("color fa");
	printf("\n\t\t\t感谢使用,按任意键退出\n\t\t\t");
return x9;
}
 

 

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值