zoukankan      html  css  js  c++  java
  • 个人作业三-ATM管理系统

    一、作业规范要求

    这个作业属于哪个课程 AHPU-软件工程导论-计算机18级
    作业要求 个人作业三-ATM管理系统
    学号 3180107121

    二、作业要求

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

    (1)开户,销户

    (2)查询账户余额

    (3)存款

    (4)取款

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

    允许网上查询参考,但请注意不要直接抄袭,可以理解看懂别人的代码,再自己编写

    三、作业内容

    1.开户

    void kaihu(struct per *head)
    {
    	head=NULL;
    	FILE *fp;   //定义文件指针
    	struct per *p1=NULL,*p2=NULL;   //p1,p2为定义链表指针
    	p1=(struct per*)malloc(sizeof(struct per));  //开辟内存单元
    	      printf("请输入您的姓名:
    ");  //请数据输入链表中
    		  scanf("%s",p1->name);
    		  printf("请设置您的卡号:
    ");
    		  scanf("%s",p1->ID);
    		  printf("请设置您银行卡密码:
    ");
    		  scanf("%s",p1->mima);
    		  p1->money=0;
    		  p1->next=NULL;
    		  printf("您的个人信息为");
    		     printf("姓名:%s 
    卡号:%s 
    余额:%4d
    ",p1->name,p1->ID,p1->money);
              if(NULL==head)           //为新用户开辟内存单元
    		  {
    			  head=(struct per *)malloc(sizeof(struct per));
    			  head->next=p1;    //进行头插法,将其作为第一个节点
    		  }
    		  else    //为新增客户开辟内存单元
    		  {
    			  for(p2=head;p2->next!=NULL;p2=p2->next); //进行尾插
    			  p2->next=p1;
    		  }
    		  if((fp=fopen("save.txt","ab+"))==NULL) //打开文件
    		  {
    			  printf("cannot poen file
    ");
    			  return;
    		  }
    		  if(fwrite(p1,sizeof(struct per),1,fp)!=1)  //将链表信息写入文件中
    			  printf("file write error
    ");
    		      fclose(fp);
    			  printf("
    ");
    			  printf("恭喜您开户成功,请登录
    ");
    			  system("pause");
    			  system("cls");
    			  denglu(head);
    }
    

    2.登录

    void denglu(struct per *head)
    {
    	char d[20];
    	char mima[20];
    	int i,j;
    	FILE *fp;     //定义文件指针
    	struct per *p,*q=NULL;
    	if((fp=fopen("save.txt","rb+"))==NULL)   //打开一个二进制文件,为读方式
    	{
    		printf("不能打开文件
    ");   //如不能打开,则结束程序
    	}
    	p=(struct per*)malloc(sizeof(struct per));   //申请空间
    	head=p;
    	while(!feof(fp))       //循环读数据直到文件尾结束
     
    	{
    		if(1!=fread(p,sizeof(struct per),1,fp))
    			break;   //如果没读到数据,跳出循环
    		p->next=(struct per *)malloc(sizeof(struct per));  //为下一个结点申请空间
    		q=p;  //保存当前节点的指针,作为下一结点的前驱
    		p=p->next;  //指针后移,新读入数据链到当前表尾
    		
    	}
    	q->next=NULL;  //最后一个结点的后继指针为空
    	fclose(fp);
    	printf("  **********************
    ");
    	printf("  ***欢迎来都建设银行***
    ");
    	printf("  **********************
    ");
    	for(j=1;j<4;j++)      //限制卡号输入的次数的循环
    	{
    		printf("请输入您的卡号
    ");
    		scanf("%s",d);
    		for(q=head;q!=NULL;q=q->next)   //遍历链表
    		{
    			if(strcmp(q->ID,d)!=0)  //核对账号
    			{
    			continue;   //跳出循环
    			}
    					else
    		{
    			for(i=1;i<4;i++)   //限制密码输入的次数的循环
    			{
    				printf("
    
    请输入您的密码
    ");
    				scanf("%s",mima);
    				if(strcmp(q->mima,mima)!=0)      //核对密码
    				{
    					printf("密码不正确。请重新输入密码
    ");
    					system("pause");
    					system("cls");
    					continue;    //若密码不对,跳出循环
    				}
    				else
    				{
    					system("cls");
    					caidan(head);   //调用菜单函数
    				}
    			}
    			printf("
    
    
    您输入密码三次错误,谢谢光临
    ");
    			system("pause");
    			system("cls");
    			exit(0);
    		}
    	}
    		
    	
    	printf("
    
    
    您输入的卡号有误,请重试
    ");
    	system("pause");
    	system("cls");
    }
    printf("您的卡号三次输入错误,谢谢使用
    ");
    exit(0);
    }
    

    3.取款

    void qukuan(struct per *head)
    {
    	head=NULL;   //head为链表头指针
    	int i;
    	FILE *fp;          //定义文件指针
    	struct per *p,*q=NULL;
    	if((fp=fopen("save.txt","rb+"))==NULL) //打开一个二进制文件,为读方式
    	{
    		printf("不能打开文件
    ");  //如不能打开,则结束程序
    	}
    	p=(struct per*)malloc(sizeof(struct per));  //申请空间
    	head=p;
    	while(!feof(fp))   //循环读数据直到文件尾结束
    	{
    		if(1!=fread(p,sizeof(struct per),1,fp))
    			break;   //如果没有读到数据,跳出循环
    		p->next=(struct per *)malloc(sizeof(struct per));  //为下一个结点申请空间
    		q=p;   //保存当前结点的指针,作为下一个结点的前驱
    		p=p->next;  //指针后移,新读入数据链到当前表尾
    	}
    	q->next=NULL;  //最后一个结点的后继指针为空
    	fclose(fp);
    	system("cls");
    	printf("************************************
    ");
        printf("**  1: 100元    *****    2:200元  **
    ");
    	printf("************************************
    ");
        printf("**  3: 300元    *****    4:400元  **
    ");
    	printf("************************************
    ");
        printf("**  5: 500元    *****    6:600元  **
    ");
    	printf("************************************
    ");
        printf("请按要求选择您要取款的金额
    ");
    	scanf("%d",&i);
    	if(i>6||i<=0)    //限制输入范围
    	{
    		printf("对不起,您的输入有误
    
    ");
    		return;
    	}
    	else
    	{
    		i=100*i;  //对应选项乘以一百为取款金额
    		if(i>q->money)
    		{
    			printf("对不起,您的金额不足
    ");
    			system("pause");
    			system("cls");
    			caidan(head);   //调用取款机菜单函数
    		}
    		else
    		{
    			q->money-=i;  //对金额进行处理
    			if((fp=fopen("save.txt","wb+"))==NULL)  //打开文件
    			{
    				printf("cannot open file
    ");
    				return;
    			}
    			if(fwrite(q,sizeof(struct per),1,fp)!=1) //将修改的信息重新写入文件
    				printf("file write error
    ");
    			printf("您已经成功取走%d元
    ");
    			q->next=NULL;
    			fclose(fp);    //关闭文件
    		}
    		
    	}
    }
    

    4.转账

    void zhuanzhang(struct per *head)
    {
    	head=NULL;
    	FILE *fp;  //定义文件指针
    	struct per *p,*q=NULL;
    	if((fp=fopen("save.txt","rb+"))==NULL)  //打开一个二进制文件,为读方式
    	{
    		printf("不能打开文件
    ");  //如不能打开,则结束程序
    	}
    	p=(struct per*)malloc(sizeof(struct per));   //申请空间
    	head=p;
    	while(!feof(fp))    //循环读数据直到文件尾结束
    	{
    		if(1!=fread(p,sizeof(struct per),1,fp))
    			break;    //如果没读到数据,跳出循环
    		p->next=(struct per *)malloc(sizeof(struct per));  //为下一个结点申请空间
    		q=p;   //保存当前结点的指针,作为下一个结点的前驱
    		p=p->next;   //指针后移,新读入数据链到当前表尾
    	}
    	q->next=NULL;   //最后一个结点的后继指针为空
    	fclose(fp);
    	int i,j,k;
    	printf("请输入帐号号码
    ");
    	scanf("%d",&i);
    	printf("请再次输入帐号号码
    ");   //核对卡号
    	scanf("%d",&j);
    	if(i!=j)
    	{
    		printf("两次账号不同,请重新输入
    ");
    		zhuanzhang(head);
    	}
    	else
    	{
    		system("cls");
    	printf("************************************
    ");
        printf("**  1: 100元    *****    2:200元  **
    ");
    	printf("************************************
    ");
        printf("**  3: 300元    *****    4:400元  **
    ");
    	printf("************************************
    ");
        printf("**  5: 500元    *****    6:600元  **
    ");
    	printf("************************************
    ");
        printf("请输入转账金额
    ");
    	scanf("%d",&k);
    	if(k>6||k<=0)
    	{
    		printf("对不起,您的输入有误
    
    ");
    		return;
    	}
    	else
    	{
    		k=k*100;
    		if(k>q->money)    //对余额进行判断
    		{
    			printf("对不起,您的余额不足
    ");
    			system("pause");
    			system("cls");
    			caidan(head);
    		}
    		else
    		{
    			printf("您已成功转账%d元
    ",k);
    			q->money-=k;
    			if((fp=fopen("save.txt","wb+"))==NULL)
    			{
    				printf("cannot open file
    ");
    				return;
    			}
    			if(fwrite(q,sizeof(per),1,fp)!=1)  //将数据重新写入文件
    				printf("file write error
    ");
    			q->next=NULL;
    			fclose(fp);
    			system("pause");
    			system("cls");
    		}
    	}
    	}
    }
     
    

    5.查询账户余额

    void chaxun(struct per *head)
    {
    	head=NULL;  //链表头指针
    	FILE *fp;  //定义文件指针
    	struct per *p,*q=NULL;
    	if((fp=fopen("save.txt","rb+"))==NULL)  //打开一个二进制文件,为读方式
    	{
    		printf("不能打开文件
    ");  //如不能打开,则结束程序
    	}
    	p=(struct per*)malloc(sizeof(struct per));   //申请空间
    	head=p;
    	while(!feof(fp))    //循环读数据直到文件尾结束
    	{
    		if(1!=fread(p,sizeof(struct per),1,fp))
    			break;    //如果没读到数据,跳出循环
    		p->next=(struct per *)malloc(sizeof(struct per));  //为下一个结点申请空间
    		q=p;   //保存当前结点的指针,作为下一个结点的前驱
    		p=p->next;   //指针后移,新读入数据链到当前表尾
    	}
    	q->next=NULL;   //最后一个结点的后继指针为空
    	fclose(fp);
    	printf("您卡上原有余额%d元
    
    ",q->money);
    	system("pause");
    	system("cls");
    }
    

    6.实验截图




    四、个人小结

    psp2.1 任务内容 计划完成需要的时间(min) 实际完成需要的时间(min)
    Planning 计划 10 30
    Estimate 估计这个任务需要多少时间,并规划大致工作步骤 10 20
    Development 开发 200 400
    Analysis 需求分析(包括学习新技术) 10 30
    Design Spec 生成设计文档 15 30
    Design Review 设计复审 5 10
    Coding Standard 代码规范 5 8
    Design 具体设计 10 50
    Coding 具体编码 100 200
    Code Review 代码复审 10 20
    Test 测试(自我测试,修改代码,提交修改) 10 20
    Reporting 报告 10 10
    Test Report 测试报告 5 10
    Size Measurement 计算工作量 3 3
    Postmortem & Process Improvement Plan 事后总结,并提出过程改进计划 10 10
  • 相关阅读:
    pandas 和 matplotlib 的设置
    Django图(菜鸟教程)
    使用 pyperclip 实现复制粘贴
    Pycharm 使用 doctest 进行判断程序是否运行正常
    jieba 运行结果不显示 Building prefix dict from the default dictionary ...
    浮点数以 .0 结尾如何转换为整数
    IOS时间转时间戳出现Invalid Date的问题
    PHP小技巧
    CSS小技巧
    树状数组
  • 原文地址:https://www.cnblogs.com/zbw7067/p/14003036.html
Copyright © 2011-2022 走看看