最新教师工资管理系统C实现资料文档格式.docx
《最新教师工资管理系统C实现资料文档格式.docx》由会员分享,可在线阅读,更多相关《最新教师工资管理系统C实现资料文档格式.docx(23页珍藏版)》请在冰豆网上搜索。
程序流程图如下:
四.详细设计
1.功能模块
共分为六个模块:
(1)输入教师信息模块
在主菜单中运用结构体teacher,输入教师信息,首先建立链表,将用户信息储存到链表中,输入完成后提示用户是否继续输入,如果用户输入“Y”,则再次调用,实现继续输入教师信息的操作。
如果用户输入”NO“,则返回主菜单界面。
(2)修改教师信息模块
在主函数中调用voidchange_id(),修改记录操作需要对数组中目标元素的数据域中的值进行操作。
首先请用户输入要修改的教师编号,然后若找到该记录就提示用户输入各个信息。
(3)删除教师信息模块
在主函数中调用voiddelete_id(),以删除教师信息,首先按学号查询教师信息,如果没有找到教师信息,给出提示。
如果找到教师信息,将教师信息显示出来,提示用户删除。
(4)查询教师信息
查询分三种,调用voidshow_all()显示所有教师信息;
调用voidsearch_id()按编号查询教师信息;
调用voidsearch_name()按姓名查询教师信息。
(5)读入教师信息文件模块
调用voidreadfromfile()函数从文件导入教师信息
(6)保存并退出模块
调用voidwritetofile()写入文件。
2.函数的设计与调用
(1)主函数的设计
编写主函数的主要任务就是确定调用函数以及控制屏幕显示。
(2)其他函数
1)原型voidshow_all;
功能展出所有录入文件
参数无
返回值无
工作方式调用charname[10];
floatsalary;
floatallowance;
floatlife;
floattel;
floatutilities;
floatrent;
floatdue;
floathealth;
floatfund;
floattotal;
floatshould;
floatactual;
2)原型voidtea_new
功能创建新的信息录入
参数无
返回值无
工作方式创建file
3)原型voidsearchmenu;
功能查找菜单
工作方式调用voidsearch_id;
voidsearch_name;
4)原型voidsearch_id;
功能查找信息按编号查找
返回值整个信息
工作方式调用number
5)原型voidsearch_name;
功能查找信息按姓名查找
工作方式调用charname
6)原型voiddelete_id
功能删除数据按编号删除
工作方式调用id
7)原型voidchange_id;
功能改变数据按编号改
返回值整个录入信息
工作方式调用id
3.数据结构的设计
定义结构体teacher,用于存放教师的信息。
structteacher
{
intnumber;
教师编号
charname[10];
教师姓名
教师基本工资
floatallowance;
教师津贴
教师生活补贴
教师电话费
floatutilities;
教师水电费
floatrent;
教师房租
floatdue;
教师所得税
教室卫生费
教师公积金
教师合计扣款
教师应发工资
教师实发工资
}tea[500];
4.算法实现
链表是算法的关键。
在添加新的数据时,可以表头插入也可以表尾插入,这两种插入方法决定了其他成员函数数据的处理。
本系统中采取的是表尾插入的方法。
在删除某信息时需要判断数据是在表头,表中还是表尾,如果删除的是在表中,则需要将删除的前后链表连接起来。
统大量运用了链表的5种基本操作:
建立链表、链表的插入、删除、输入和查找。
5.程序清单
#include<
stdio.h>
string.h>
#include<
stdlib.h>
conio.h>
/*教师工资管理系统结构体定义*/
intnum=0;
FILE*fp;
voidmainmenu();
voidreadfromfile();
voidwritetofile();
voidshow_all();
voidtea_new();
voidsearchmenu();
voidsearch_id();
voidsearch_name();
voiddelete_id();
voidchange_id();
voidmain()
readfromfile();
while
(1)
{
mainmenu();
}
}
//主菜单
voidmainmenu()
charchoic;
system("
cls"
);
printf("
\t----------------欢迎使用\(^o^)/~-------------------\n"
\t****************教师工资管理系统******************\n\n"
\t---------------[1]输入教师信息--------------------\n"
\t---------------[2]修改教师信息--------------------\n"
\t---------------[3]删除教师信息--------------------\n"
\t---------------[4]查询教师信息--------------------\n"
\t---------------[5]保存并退出----------------------\n"
\t**************************************************\n"
\t请输入所需的服务项目序号:
\n"
choic=getch();
switch(choic)
case'
1'
:
tea_new();
break;
2'
change_id();
3'
delete_id();
4'
searchmenu();
5'
writetofile();
default:
mainmenu();
//从文件导入
voidreadfromfile()
if((fp=fopen("
teacher.bin"
"
rb"
))==NULL)
printf("
\n\t教师工资信息文件不存在哟(*/ω╲*)"
if((fp=fopen("
wb"
{
printf("
\n\t建立失败"
exit(0);
}
else
\n\t教师工资信息文件已建立(~o ̄3 ̄)~"
\n\t按回车键进入主菜单"
getch();
return;
exit(0);
fseek(fp,0,2);
if(ftell(fp)>
0)
rewind(fp);
for(num=0;
!
feof(fp)&
&
fread(&
tea[num],sizeof(structteacher),1,fp);
num++);
printf("
\n\t教师工资信息文件导入成功(* ̄3 ̄)╭"
\n\t文件中无任何记录(=@__@=)"
return;
//写入文件
voidwritetofile()
inti;
\n\t打开文件失败(*/ω╲*)"
for(i=0;
i<
num;
i++)
if(fwrite(&
tea[i],sizeof(structteacher),1,fp)!
=1)
\n\t文件写入错误!
(>﹏<)\n"
fclose(fp);
\n\t教师工资信息文件已保存"
\n\t按任意键退出程序(* ̄ω ̄)\n\t"
exit(0);
//添加记录
voidtea_new()
请输入教师号:
"
scanf("
%d"
&
tea[num].number);
请输入教师姓名:
%s"
tea[num].name);
请输入教师基本工资:
%f"
tea[num].salary);
请输入教师的津贴:
tea[num].allowance);
请输入教师的生活补贴:
tea[num].life);
请输入教师的电话费:
tea[num].tel);
请输入教师的水电费:
tea[num].utilities);
请输入教师的房租:
tea[num].rent);
请输入教师的所得税:
tea[num].due);
请输入教师的卫生费:
tea[num].health);
请输入教师的公积金:
tea[num].fund);
tea[num].should=tea[num].salary+tea[num].allowance+tea[num].life;
tea[num].total=tea[num].tel+tea[num].utilities+tea[num].rent+tea[num].due+tea[num].health+tea[num].fund;
tea[num].actual=tea[num].should-tea[num].total;
num++;
是否继续添加?
(Y/N)"
if(getch()=='
y'
)
tea_new();
//查询菜单
voidsearchmenu()
\n\t------------查询-------------------"
\n\t--------[1]显示所有----------------"
\n\t--------[2]按编号查询--------------"
\n\t--------[3]按姓名查询--------------"
\n\t--------[4]返回主菜单--------------"
\n\t请选择:
\n"
{
show_all();
search_id();
search_name();
}
//显示所有
voidshow_all()
if(num!
=0)
{
\n\t编号:
%d"
tea[i].number);
\n\t姓名:
%s"
tea[i].name);
\n\t基本工资:
%.5f"
tea[i].salary);
\n\t津贴:
tea[i].allowance);
\n\t生活补贴:
tea[i].life);
\n\t电话费:
tea[i].tel);
\n\t水电费:
tea[i].utilities);
\n\t房租:
tea[i].rent);
\n\t所得税:
tea[i].due);
\n\t卫生费:
tea[i].health);
\n\t公积金:
tea[i].fund);
\n\t应发工资:
tea[i].should);
\n\t合计扣款:
tea[i].total);
\n\t实发工资:
tea[i].actual);
if(i+1<
num)
{
\n\t_____________________"
pause"
}
}
\n\t*************************************"
else
\n\t文件中无记录┭┮﹏┭┮"
\n\t按回车键回到主菜单"
getch();
//按编号查询
voidsearch_id()
intmark=0;
inti,a=0;
intid;
\n\t请输入编号:
id);
if(id==tea[i].number)
\n\t******以下是你要查找的教师工资信息******\n"
mark++;
if(mark==0)
\n\t没有该编号的信息"
\n\t按回车键返回主菜单"
//按姓名查询
voidsearch_name()
请输入姓名:
name);
for(i=a;
if(strcmp(tea[i].name,name)==0)
if((i+1)<
{
\t\n是否继续查找相同名字的教师信息:
(y/n)"
if(getch()=='
{
a=i;
continue;
}
}
if(mark!
\n\t没有相同姓名的教师信息记录"
//删除菜单
voiddelete_id()
inti,j;
intdeletemark=0;
\n\t情输入要删除的编号:
if(num==0)
\n\t对不起,文件中无任何教师工资信息记录"
if(id==tea[i].num