活期储蓄账目管理系统doc.docx
《活期储蓄账目管理系统doc.docx》由会员分享,可在线阅读,更多相关《活期储蓄账目管理系统doc.docx(29页珍藏版)》请在冰点文库上搜索。
活期储蓄账目管理系统doc
《数据结构》课程设计
课程设计题目:
活期存储账目管理系统
姓名:
院系:
计算机学院
专业:
计算机科学与技术
年级:
11级
学号:
指导教师:
2013年10月12日
目录
1课程设计的目的…………………………………………………1
2需求分析…………………………………………………………1
3课程设计报告内容………………………………………………1
3.1概要设计………………………………………………………1-2
3.2详细设计……………………………………………………2-10
3.3调试分析……………………………………………………10-12
3.4用户手册………………………………………………………13
3.5测试结果………………………………………………………13
3.6程序清单……………………………………………………13-24
4小结……………………………………………………………24
5参考文献……………………………………………………24-25
1课程设计的目的
设计活期储蓄帐目管理系统的要求:
活期储蓄处理中,储户开户、销户、存入、支出活动频繁,系统设计要求:
①能比较迅速地找到储户的帐户,以实现存款、取款记账;
②能比较简单,迅速地实现插入和删除,以实现开户和销户的需要。
设计这个活期账目管理系统可以方便银行人员进行管理和调试,从而也能提
高我们的编程技能
熟练使用C语言编写程序,解决实际问题;
了解并掌握数据结构与算法的设计方法,具备初步的独立分析和设计能力;初步掌握软件开发过程的问题分析、系统设计、程序编码、测试等基本方法和技能;提高综合运用所学的理论知识和方法独立分析和解决问题的能力;
2需求分析
(1)创建文件,用数组形式存储用户数据,开户时自定义用户账户、
姓名、密码、开户金额。
(2)用户登录时,输入正确的用户姓名、用户密码,完成登录后即可进行存款、取款、
查询、修改密码。
(也可以输入用户账号、用户密码)
(3)实现输入用户的账户名和密码,将其全部信息删除,进行销户。
3课程设计报告内容
3.1概要设计
在本课程设计的方案设计中,已经确定了用链表来作为数据的存储结构(也可以不用单链表),所以这里我没有采用单链表作为其存储结构,首先用结构体来定义其数据类型,然后将数据按照该数据结构存储,之后运用文件的相关知识将更改的数据写入文件中,这样就完成了本课程设计的方案设计。
为了实现需求分析中的功能,可以从以下几个方面着手设计。
(1)数据结构设计
该课程设计的数据结构是线性的数据存储结构,采用的是数组类型的存储结构。
(2)存储结构设计
该存储结构是链式存储结构,本系统主要用线性表表结构类型来存储在“活期储蓄账目管理系统”中的信息。
其中,结构体由4个分量构成:
用户账号名、用户姓名、用户密码、开户金额。
(3)模块设计
(4)模块功能分析及其外部设计
开户模块主要是输入需要开户的姓名,然后建立开户账号,提醒输入账号密码。
销户模块则是输入需要销户的账号及其密码,然后从系统中销去些账号的相关记录。
同样存款是根据提醒输入需要登录的账号,然后再输入其密码,之后就可以查看其账号上的相关资料。
取款则是要求登录需要存入及其支出的账号,然后对该账号进行相关的存入及支出。
程序的外部设计主要是通过编写一个菜单功能来实现各个模块功能的调用,从而更好
的协调各个模块功能之间的关系,同时还要编写一段代码来实现所有数据更改后将其写入文件中,实现数据的及时更新,维护数据的正确性.
3.2详细设计
(1)数据类型定义
本系统采用链式结构存储储蓄账目管理系统结构。
结点定义如下:
structuser
{
charname[20];
intid;
charpassword[8];
doublemoney;
}
(2)系统主要子程序详细设计
用户输入要想开户的储户输入其姓名账户密码,然后显示开户
成功,会有一个账户号生成,则开户就成功了。
可以设计账户开户函数:
add();
用户登录需要输入账户名和密码,判断密码是否正确,如果错误则返回,
然后点击登录,就可以进入管理系统。
则需要设计用户信息输入函数:
getuser();
用户的存取款和查询余额,首先在登录账户的基础上,选择存或者取款,然后输入
相应的金额,若是取款应判断其金额是否小于账户上的金额,如果不小于,则提示
储户重新输入相应的金额,或者退出。
可以设计存款函数:
save_money();取款函数:
get_money();
查询余额函数(用名字进行查询):
select_name();查找用户账号函数:
select_name();
储户输入需要销户的账号,然后程序自动判断该账号是否存在,然后输入账号密码,
若账号与密码相对应,则删除该账号。
可以设计函数销户函数:
del();系统显示函数dispaly();
1用户开户函数
voidadd()
{
printf("%30s\n","***用户开户***");
printf("---------------------------------------------\n\n");
structusergetuser();
intcount();
FILE*fp;
intnumber;
structusertemp;
if((fp=fopen(file,"ab"))==NULL)
{
printf("cannotopenfile!
\n");
exit
(1);
}
temp=getuser();
number=count();
temp.id=number+1;
fwrite(&temp,sizeof(structuser),1,fp);
printf("用户开户成功!
\n");
fclose(fp);
}
2.按姓名查询帐户余额
voidselect_name()
{
voidgetname(char*name);
voidgetpassword(char*password);
printf("%30s\n","***按照姓名查询账户余额***");
printf("%8s%15s%15s%10s\n","账号","用户姓名","存款余额");
printf("---------------------------------------------\n\n\n");
FILE*fp;
structusertemp;
charname[20];
charpassword[8];
if((fp=fopen(file,"rb"))==NULL)
{
printf("cannotopenfile!
\n");
exit
(1);
}
printf("输入要查询的姓名:
");
getname(name);
printf("请输入密码:
");
getpassword(password);
while(fread(&temp,sizeof(structuser),1,fp))
if(strcmp(temp.name,name)==0&&strcmp(temp.password,password)==0)
{
printf("NO.%d%20s%.2f\n",temp.id,temp.name,temp.money);
}
fclose(fp);
}
按账号查询账户余额
voidselect_id()
{
intcount();
voidgetpassword(char*password);
printf("%30s\n","***按照编号查询账户余额***");
printf("%8s%15s%10s\n","编号","用户姓名","存款余额");
printf("---------------------------------------------\n\n");
FILE*fp;
structusertemp;
inti,maxnum;
charpassword[8];
if((fp=fopen(file,"rb"))==NULL)
{
printf("cannotopenfile!
\n");
exit
(1);
}
maxnum=count();
printf("输入要查询账号:
");
scanf("%d",&i);
printf("输入账号密码:
");
scanf("%s",&password);
if(i<1||i>maxnum)
{
printf("你要查询的账号不存在!
");
return;
}
while(fread(&temp,sizeof(structuser),1,fp))
if(temp.id==i&&strcmp(temp.password,password)==0)
{
printf("NO.%d%20s%.2f\n",temp.id,temp.name,temp.money);
}
fclose(fp);
}
显示用户资料
voiddisplay()
{
printf("%30s\n","***用户资料显示***");
printf("%8s%15s%10s\n","账号","用户姓名","存款余额");
printf("---------------------------------------------\n\n");
FILE*fp;
structusertemp;
if((fp=fopen(file,"rb"))==NULL)
{
printf("cannotopenfile!
\n");
exit
(1);
}
while(fread(&temp,sizeof(structuser),1,fp))
{
printf("NO.%d%20s%.2f\n",temp.id,temp.name,temp.money);
}
fclose(fp);
}
储户存款
voidsave_money()
{
printf("%30s\n","***用户存款业务***");
printf("---------------------------------------------\n\n");
intcount();
voidgetpassword(char*password);
FILE*fp;
inti,num,mark;
structuser*temp;
charpassword[8];
num=count();
temp=(structuser*)malloc(num*sizeof(structuser));
if((fp=fopen(file,"rb"))==NULL)
{
printf("cannotopenfile!
\n");
exit
(1);
}
for(i=0;ifread(&temp[i],sizeof(structuser),1,fp);
fclose(fp);
printf("输入要存款账号:
");
scanf("%d",&mark);
if(mark<1||mark>num)
{
printf("你要存款账号不存在!
");
return;
}
printf("输入账号密码:
");
scanf("%s",&password);
if((fp=fopen(file,"wb"))==NULL)
{
printf("cannotopenfile!
\n");
exit
(1);
}
for(i=0;i{
if(temp[i].id==mark)
{
doublemoney=0;
printf("输入要存入的金额:
");
scanf("%lf",&money);
if(money<=0)
{
printf("只能为正数!
\n");
money=0;
}
temp[i].money+=money;
}
fwrite(&temp[i],sizeof(structuser),1,fp);
}
fclose(fp);
free(temp);
printf("你存款业务已办妥!
\n");
}
储户取款
voidget_money()
{
printf("%30s\n","***用户取款业务***");
printf("---------------------------------------------\n\n");
intcount();
voidgetpassword(char*password);
FILE*fp;
inti,num,mark;
structuser*temp;
charpassword[8];
num=count();
temp=(structuser*)malloc(num*sizeof(structuser));
if((fp=fopen(file,"rb"))==NULL)
{
printf("cannotopenfile!
\n");
exit
(1);
}
for(i=0;ifread(&temp[i],sizeof(structuser),1,fp);
fclose(fp);
printf("输入要取款账号:
");
scanf("%d",&mark);
if(mark<1||mark>num)
{
printf("你要取款账号不存在!
");
return;
}
printf("输入账号密码:
");
scanf("%s",&password);
if((fp=fopen(file,"wb"))==NULL)
{
printf("cannotopenfile!
\n");
exit
(1);
}
for(i=0;i{
if(temp[i].id==mark)
{
doublemoney=0;
printf("输入要取出的金额:
");
scanf("%lf",&money);
if(money<=0)
{
printf("只能为正数!
\n");
money=0;
}
else
if(money>temp[i].money)
{
printf("你的余额不足!
\n");
money=0;
}
temp[i].money-=money;
}
fwrite(&temp[i],sizeof(structuser),1,fp);
}
fclose(fp);
free(temp);
printf("你取款业务已办妥!
\n");
}
销户
voiddel()
{
intcount();
printf("%30s\n","***注销账户***");
printf("%8s%15s%10s\n","账号","用户姓名","存款余额");
printf("---------------------------------------------\n\n");
FILE*fp;
structusertemp;
inti,maxnum;
if((fp=fopen(file,"rb"))==NULL)
{
printf("cannotopenfile!
\n");
exit
(1);
}
maxnum=count();
printf("输入要销户账号:
");
scanf("%d",&i);
if(i<1||i>maxnum)
{
printf("你要查询的账号不存在!
");
return;
}
while(fread(&temp,sizeof(structuser),1,fp))//循环读取每一条记录判断是否为要查看的记录
if(temp.id==i&&temp.money==0.00)//余额为0
{temp.id=-1;//算无效帐户
printf("NO.%d%20s%.2f\n",temp.id,temp.name,temp.money);
fwrite(&temp,sizeof(structuser),1,fp);//保存修改
printf("账户销户成功\n");
}
fclose(fp);
}
3.3调试分析
系统运行主界面如图所示,各子功能测试运行结果如下。
每个方面实现一个功能。
定义一个包含有四个变量的结构体数组,并存入文件中。
定义一个计数函数,贯穿整个程序。
然后每个函数实现一个功能,共有七个功能。
添加用户时会使用到录入姓名和录入身份证号码两个函数。
按姓名和账号查询只需要比较字符串,然后输出即可实现。
显示用户资料只需将结构体数组依次输出即可实现。
储户的存款和取款按找账号依次从文件中查找到匹配的账号,然后加上或减去存取的金额即可实现。
销户时将金额为零的账户账号标为-1即可。
1.主界面截图
2.用户开户
3.按照姓名查找账户
4.按照账号查找账户
5.用户存款
6.用户取款
7.用户销户前显示用户信息
进行销户
3.4用户手册
(1)本程序执行文件为”活期储蓄.exe”.
(2)进入本系统后,随即显示系统主菜单页面,用户可在该界面下输入各子菜单前对应的数字并按回车键,执行相应子菜单命令。
3.5测试结果
最后以文件输出的数据(有点乱码)
3.6程序清单
#include
#include
#include
#include
#definefile"temp.txt"
structuser
{
intid;
charname[20];
charpassword[6];
doublemoney;
};
voidadd()
{
printf("%30s\n","***用户开户***");
printf("---------------------------------------------\n\n");
structusergetuser();
intcount();
FILE*fp;
intnumber;
structusertemp;
if((fp=fopen(file,"ab"))==NULL)
{
printf("cannotopenfile!
\n");
exit
(1);
}
temp=getuser();
number=count();
temp.id=number+1;
fwrite(&temp,sizeof(structuser),1,fp);
printf("用户开户成功!
\n");
fclose(fp);
}
intcount()
{
FILE*fp;
intnum;
structusertemp;
num=0;
if((fp=fopen(file,"rb"))==NULL)
{
printf("cannotopenfile!
\n");
exit
(1);
}
while(fread(&temp,sizeof(structuser),1,fp))
{
num++;
}
fclose(fp);
returnnum;
}
voidgetname(char*name)
{
do
{
scanf("%s",name);
fflush(stdin);
if(strlen(name)==0)
printf("姓名不能为空!
\n");
elseif(strlen(name)>=20)
printf("姓名不能超过20个字符!
\n");
else
break;
printf("重新输入姓名:
");
}
while
(1);
}
voidgetpassword(char*password)
{
do
{
inti,j;
charch;
for(i=0,j=0;;i++)
if((ch=getchar())!
='\n')
{
if(ch<='9'&&ch>='0')
password[i]=ch;
else
{
printf("密码只能是数字!
\n");
j=1;
break;
}
}
else
break;
password[i]='\0';
if(j==1)
continue;
if(strlen(password)!
=6)
printf("密码只能是6位!
\n");
else
break;
printf("重新输入密码:
");
}
while
(1);
}
structusergetuser()
{
voidgetname(char*name);
voidgetpassword(char*password);
structusertemp;
printf("请输入用户姓名:
");
getname(temp.name);
printf("请输入用户密码:
");
getpassword(temp.password);
printf("输入开户金额:
");
do
{
scanf("%lf",&temp.money);
fflush(stdin);
if((temp.money)<10)
printf("开户金额不能小于10\n");
else
break;
printf("重新输入开户金额:
");
}
while
(1);
returntemp;
}
voidselect_name()
{
voidgetname(char*name);
voidgetpassword(char*password);
printf("%30s\n","***按照姓名查询账户余额***");
printf("%8s%15s%15s%10s\