个人作业三-ATM管理系统

个人作业三-ATM管理系统

一、作业要求

博客班级 博客班级链接
作业要求 作业要求链接
作业目标 编写一个ATM管理系统并完成基本功能
学号 3180701129

二、题目要求

编写一个ATM管理系统,语言不限,要求应包括以下主要功能:

(1)开户,销户

(2)查询账户余额

(3)存款

(4)取款

(5)转账(一个账户转到另一个账户)等...

三、代码编写

1、结构体创建

struct node
{
	char Name[40];		//姓名
	char Id[40];		//身份证号
	char key[20];		//密码
	int Money;			//余额
	struct node *link;
};

2、登录

struct node *Login(struct node *L) //登录
{
	struct node *p = NULL;
	char personal_Id[40], personal_key[20];

	printf("请输入您的身份证号:");
	getchar();
	gets(personal_Id);
	printf("请输入您的密码:");
	gets(personal_key);

	for (p = L->link; p != NULL; p = p->link)
	{
		if ((strcmp(p->Id, personal_Id) == 0) && (strcmp(p->key, personal_key) == 0))
		{
			return p;
		}
	}
	return p;
}

3、注册

struct node *CreateAccount(struct node *L) 		//注册
{
	int i = 1;
	struct node *p = NULL;

	p = (struct node *)malloc(sizeof(struct node));
	getchar();
	printf("\n  姓名:");
	gets(p->Name);
	printf("  身份证号:");
	gets(p->Id);
	printf("  密码:");
	gets(p->key);
	p->Money = 0;
	p->link = L->link;
	L->link = p;
	printf("\n");

	printf("账户创建成功!\n\n");
	system("pause");
	return L;
}

4、查询

void Query(struct node *p) //查询(输出用户的个人信息)
{
	printf("		姓名:%s\n\n", p->Name);
	printf("		身份证号:%s\n\n", p->Id);
	printf("		余额:%d\n\n", p->Money);

	system("pause");
}

5、存款

struct node *Deposit(struct node *p) //存款
{
	int num;
	printf("存款金额为:");
	scanf("%d", &num);
	p->Money = p->Money + num;

	printf("存款成功,剩余金额为:%d\n", p->Money);

	system("pause");

	return p;
}

6、取款

struct node *Withdraw_Money(struct node *p) //取款
{
	int num;
	printf("取款金额为:");
	scanf("%d", &num);
	p->Money = p->Money - num;

	printf("取款成功,剩余金额为:%d\n", p->Money);

	system("pause");

	return p;
}

7、转账

struct node *Transfer_Accounts(struct node *L, struct node *p) 		//转账
{
	int num;
	char Other_Id[40];
	struct node *q;
	printf("请输入收款人的身份证号:");
	getchar();
	gets(Other_Id);

	for ( q = L->link; q != NULL; q = q->link)
	{
		if (strcmp(q->Id, Other_Id) == 0)
		{
			break;
		}
		
	}

	printf("请输入转账金额:");
	scanf("%d",&num);

	p->Money = p->Money - num;
	q->Money = q->Money + num;

	printf("转账成功,剩余金额为:%d\n",p->Money);

	system("pause");
	return p;
	
}

8、销户

void Delect(struct node *L, struct node *p)		//销户
{
	struct node *q1;
	struct node *q2;
	int n;
	printf("是否销毁此账户。\n");
	printf("1: 是	 0:不是\n");
	scanf("%d",&n);
	if (n)
	{
		q1 = L;
		for ( q2 = q1->link; q2 != NULL; q1 = q2, q2 = q1->link)
		{
			if (strcmp(q2->Id, p->Id) == 0)
			{
				q1->link = q2->link;
				free(p);
				break;
			}
			
		}

		printf("账户已成功销毁!\n\n");
		
	}
	
}

9、主程序

int main()
{
	struct node *L = NULL;
	struct node *personal = NULL;

	int select1, select2;

	FILE *fp;
	fp = fopen("file.txt", "a+");				//建立文件存储用户信息
	if (fp == -1)
		fp = fopen("file.txt", "w");
	fclose(fp);

	L = InitList(L);			//链表初始化
	L = Read(L);				//读取文件

	select1 = menu1();
	switch (select1)
	{
	case 1:
		personal = Login(L);

		if (personal != NULL)
		{
			select2 = menu2();

			switch (select2)
			{
			case 1:
				Query(personal);
				break;

			case 2:
				personal = Deposit(personal);
				Preserve(L);
				break;

			case 3:
				personal = Withdraw_Money(personal);
				Preserve(L);
				break;

			case 4:
				personal = Transfer_Accounts(L, personal);
				Preserve(L);
				break;

			case 5:
				Delect(L, personal);
				Preserve(L);
				break;

			default:
				break;
			}
		}
		else
		{
			printf("身份证号号或密码错误!");
		}

		break;

	case 2:
		L = CreateAccount(L);
		Preserve(L);
		break;

	default:
		break;
	}

	getchar();
	return 0;
}

四、运行截图

1、注册截图

2、登录截图

3、查询截图

4、存款截图

5、取款截图

6、转账截图

7、销户截图

五、个人小结

psp2.1 任务内容 计划完成需要的时间(min) 实际完成需要的时间(min)
Planning 计划 10 10
Estimate 估计这个任务需要多少时间,并规划大致工作步骤 10 10
Development 开发 200 180
Analysis 需求分析(包括学习新技术) 15 10
Design Spec 生成设计文档 20 20
Design Review 设计复审 10 8
Coding Standard 代码规范 15 13
Design 具体设计 15 15
Coding 具体编码 20 30
Code Review 代码复审 10 7
Test 测试(自我测试,修改代码,提交修改) 10 10
Reporting 报告 20 15
Test Report 测试报告 15 13
Size Measurement 计算工作量 20 15
Postmortem & Process Improvement Plan 事后总结,并提出过程改进计划 15 15
posted @ 2020-11-19 00:43  0I_I0  阅读(130)  评论(0编辑  收藏  举报