【C++】银行存取款管理系统

一、 定义结构体

#include"stdio.h"
#include"iostream"
#include"string.h"
#include<windows.h>

using namespace std;
int num=0;
struct Login{//登录结构体,有用户名和密码 
	char username[10];
	char password[10];
}lg[100];
struct Customerinfo{
	char idcard[10];
	char cuname[20];
	char cupwd[10];
	char cuaddr[30];
	char phone[11];
	float total;
}customer[100];
struct record{
	char idcard[10];
	char date[12];
	char category[8];
	float number;
	char Handler[20];
}dwrecord[1000];

二、实现系统登录功能

int SystemLogin(char *uname,char *pword){//系统登录功能 
	FILE *fp;
	int i;
	if((fp=fopen("login.txt","r"))==NULL){
		printf("文件打开失败!\n");
		return 0;
	}
	for(i=0;!feof(fp);i++){
		fscanf(fp,"%s%s",&lg[i].username,&lg[i].password);
		if((strcmp(lg[i].username,uname)==0)&&(strcmp(lg[i].password,pword)==0))
			return 1;
	}
	fclose(fp);
	return 0;
}

 三、主界面设计

int display(){//主界面 
	int m;
	printf("--欢迎使用银行存取款系统,请选择你要执行的操作--\n");
	printf("------------------------------------------------\n");
	printf("--   0.退出系统                  1.录入信息   --\n"); 
	printf("--   2.存储                      3.取款       --\n");
	printf("--   4.存款查询                  5.取款查询   --\n");
	printf("--   6.显示信息                  7.删除信息   --\n");
	printf("--   8.修改信息                  9.存取款统计 --\n");
	printf("--   10.客户存取款排序                        --\n");
	printf("------------------------------------------------\n");
	printf("请输入您的选择(0-10)\n");
	scanf("%d",&m);
	while(m>10||m<0){
		printf("你选择的编号有误请重新输入\n");
		scanf("%d",&m);
	}
	return m;
}

 四、录入信息功能的实现

void insertcustomer(){//录入客户的账号信息 
	FILE *fp;
	int i,j,total;
	char c;
	if((fp=fopen("Customerinfo.txt","r"))==NULL){
		printf("文件打开失败!\n");
	}
	for(j=0;!feof(fp);j++){
		total++;
		fscanf(fp,"%s%s%s%s%s%f",&customer[j].idcard,&customer[j].cuname,&customer[j].cupwd,&customer[j].cuaddr,&customer[j].phone,&customer[j].total);
	}
	fp=fopen("Customerinfo.txt","a");
	for(i=0;i<100;i++){
		printf("请输入%d个人的信息",i+1);
		printf("编号:");
		scanf("%s",&customer[i].idcard);
		printf("客户姓名:");
		scanf("%s",&customer[i].cuname);
		printf("支取密码:");
		scanf("%s",&customer[i].cupwd);
		printf("客户地址:");
		scanf("%s",&customer[i].cuaddr);
		printf("客户电话:");
		scanf("%s",&customer[i].phone);
		printf("账户总金额:");
		scanf("%f",&customer[i].total);
		if((i+1)%1==0){
			getchar();
			printf("是否继续录入客户信息(y|Y)");
			scanf("%c",&c);
			if(c!='Y'&&c!='y')
				break;
		}
	}
	if(total>0)
		fprintf(fp,"\n","");
	for(int j=0;j<=i;j++){
		if(j<i-1)
			fprintf(fp,"%s\t%s\t%s\t%s\t%s\t%f\n",customer[j].idcard,customer[j].cuname,customer[j].cupwd,customer[j].cuaddr,customer[j].phone,customer[j].total);
		else
			fprintf(fp,"%s\t%s\t%s\t%s\t%s\t%f",customer[j].idcard,customer[j].cuname,customer[j].cupwd,customer[j].cuaddr,customer[j].phone,customer[j].total);
	}
	fclose(fp);
	printf("数据保存成功,按回车键继续...");
	getchar();
	getchar();
}

五、存款功能的实现 

void deposit(){//存款操作 
	system("cls");//清屏
	printf("正在进行存款操作...\n");
	int i,j,flag=0,n=0,m=0;
	float k;
	FILE *fp,*ap;
	if((fp=fopen("Customerinfo.txt","r"))==NULL){
		printf("文件打开失败!\n");
		return;
	}
	printf("请输入客户编号:\n");
	scanf("%s",&dwrecord[m].idcard);
	for(i=0;!feof(fp);i++){//读取用户信息,判断所要进行存款操作的账户是否存在 
		fscanf(fp,"%s%s%s%s%s%f",&customer[i].idcard,&customer[i].cuname,&customer[i].cupwd,&customer[i].cuaddr,&customer[i].phone,&customer[i].total);
		if(strcmp(customer[i].idcard,dwrecord[m].idcard)==0){
			flag=1;
			n=i;
		}
	}
	if(flag){//找到相应的账户,进行存款操作 
		ap=fopen("record.txt","a")
评论 34
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值