高校教师工资管理系统.docx

上传人:b****8 文档编号:10158416 上传时间:2023-02-08 格式:DOCX 页数:20 大小:17.88KB
下载 相关 举报
高校教师工资管理系统.docx_第1页
第1页 / 共20页
高校教师工资管理系统.docx_第2页
第2页 / 共20页
高校教师工资管理系统.docx_第3页
第3页 / 共20页
高校教师工资管理系统.docx_第4页
第4页 / 共20页
高校教师工资管理系统.docx_第5页
第5页 / 共20页
点击查看更多>>
下载资源
资源描述

高校教师工资管理系统.docx

《高校教师工资管理系统.docx》由会员分享,可在线阅读,更多相关《高校教师工资管理系统.docx(20页珍藏版)》请在冰豆网上搜索。

高校教师工资管理系统.docx

高校教师工资管理系统

//高校教师工资管理系统源代码

#include

usingnamespacestd;

#include

#include//文件流

classTeacher//教职工类(抽象类)

{

protected:

intnum;//编号

charname[20];//允许不超过20个字符的姓名

intage;//工龄

intflag;//职工类别标志(0:

助教,1:

讲师,2:

副教授,3:

教授,4:

行政管理人员,5:

讲师兼行政管理人员)

doublesalary;//职工基本工资

Teacher*next;//指针域存放指向下一个结点的指针,以实现链表彻底线

型结构

public:

Teacher()//基类构造

{

next=NULL;//指针域设置为空

}

virtual~Teacher()//基类虚析构

{

}

virtualvoidInput()=0;//从键盘输入数据

virtualvoidInput(ifstream&ifs)=0;//从文件输入数据

virtualvoidOutput()=0;//向屏幕输出数据

virtualvoidOutput(ofstream&ofs)=0;//向文件输出数据

virtualdoubleincoming()=0;//计算收入

friendclassTeacher_Manager;//定义Teacher友元类以便访问其私有、保护成员

};

classAssistant:

virtualpublicTeacher//助教类,虚继承

{

protected:

inthours;//助教课时

public:

Assistant()//构造函数,初始化部分数据

{

flag=0;

salary=960;

}

voidInput()//键盘补充输入其它数据

{

cout<<"编号:

";cin>>num;

cout<<"姓名:

";cin>>name;

cout<<"工龄:

";cin>>age;

cout<<"助教上学期课时:

";cin>>hours;

}

voidInput(ifstream&ifs)//ifs是输入文件流的对象

{

ifs>>num>>name>>age>>flag>>hours;

}

voidOutput()

{

cout<

工资:

"<

}

voidOutput(ofstream&ofs)//ofs是输出文件流的对象

{

ofs<

资:

"<

}

doubleincoming()

{

returnsalary+hours*30+age*20;

}

};

classLecturer:

virtualpublicTeacher//讲师

{

protected:

intAllowance;

inthours;

public:

Lecturer()

{

flag=1;

salary=1100;

Allowance=150;

}

voidInput()

{

cout<<"编号:

\n";cin>>num;

cout<<"姓名:

\n";cin>>name;

cout<<"工龄:

";cin>>age;

cout<<"讲师上学期课时:

";cin>>hours;

}

voidInput(ifstream&ifs)

{

ifs>>num>>name>>age>>flag>>hours;

}

voidOutput()

{

cout<

"<

}

voidOutput(ofstream&ofs)

{

ofs<

"<

}

doubleincoming()

{

returnsalary+Allowance+hours*30+age*25;

}

};

classAssociate_professor:

virtualpublicTeacher//副教授

{

protected:

intAllowance;

inthours;

public:

Associate_professor()

{

flag=2;

salary=1300;

Allowance=250;

}

voidInput()

{

cout<<"编号:

";cin>>num;

cout<<"姓名:

";cin>>name;

cout<<"工龄:

";cin>>age;

cout<<"副教授上课课时:

";cin>>hours;

}

voidInput(ifstream&ifs)

{

ifs>>num>>name>>age>>flag>>hours;

}

voidOutput()

{

cout<

"<

}

voidOutput(ofstream&ofs)//向文件输出数据

{

ofs<

"<

}

doubleincoming()

{

returnsalary+Allowance+age*30+hours*40;

}

};

classProfessor:

virtualpublicTeacher//教授

{

protected:

inthours;

intAllowance;

public:

Professor()

{

flag=3;

salary=1500;

Allowance=350;

}

voidInput()

{

cout<<"编号:

";cin>>num;

cout<<"姓名:

";cin>>name;

cout<<"工龄:

";cin>>age;

cout<<"教授上学期课时:

";cin>>hours;

}

voidInput(ifstream&ifs)

{

ifs>>num>>name>>age>>flag>>hours;

}

voidOutput()

{

cout<

"<

}

voidOutput(ofstream&ofs)

{

ofs<

"<

}

doubleincoming()

{

returnsalary+Allowance+hours*50+age*40;

}

};

classAdministrative_staff:

virtualpublicTeacher//行政人员

{

protected:

inthours;

public:

Administrative_staff()

{

flag=4;

salary=1500;

}

voidInput()

{

cout<<"编号:

";cin>>num;

cout<<"姓名:

";cin>>name;

cout<<"工龄:

";cin>>age;

cout<<"行政人员上班时间:

";cin>>hours;

}

voidInput(ifstream&ifs)

{

ifs>>num>>name>>flag>>hours;

}

voidOutput()

{

cout<

"<

}

voidOutput(ofstream&ofs)

{

ofs<

"<

}

doubleincoming()

{

returnsalary+hours*15;

}

};

classLecturer_staff:

publicLecturer,publicAdministrative_staff//讲师与行政人员双重身份

{

public:

Lecturer_Assistant()

{

flag=5;

}

voidInput()

{

cout<<"编号:

";cin>>num;

cout<<"姓名:

";cin>>name;

cout<<"讲师工龄:

";cin>>age;

cout<<"讲师上学期课时:

";cin>>Lecturer:

:

hours;

cout<<"行政上班时间:

";cin>>Administrative_staff:

:

hours;

}

voidInput(ifstream&ifs)

{

ifs>>num>>name>>flag>>age>>Lecturer:

:

hours>>Administrative_staff:

:

hours;

}

voidOutput()

{

cout<

:

hours

<<'('<

:

hours<<')'<<"\t"<<"工资:

"<

}

voidOutput(ofstream&ofs)

{

ofs<

:

hours<<"\t"

<

:

hours<<"\t"<<"工资:

"<

}

doubleincoming()

{

returnsalary+Lecturer:

:

hours*30+Allowance+Administrative_staff:

:

hours*15+age*10;

}

};

classTeacher_Manager

{

private:

Teacher*PL;

intTeacher_Manager:

:

Find(intID,Teacher**p1,Teacher**p2);

public:

Teacher_Manager();//构造

~Teacher_Manager();//析构

voidAdd();//增加职工

voidDelete();//删除职工

voidModify();//修改职工

voidPrint();//输出职工信息

voidAve_salary();//计算职工平均工资

voidSave();//职工信息存盘

};

Teacher_Manager:

:

Teacher_Manager()//构造函数(创建1个头结点的链表)

{

Teacher*p=newAssistant;

PL=p;

cout<

cout<<"欢迎进入高校职工工资管理系统!

"<

}

Teacher_Manager:

:

~Teacher_Manager()//析构函数(仅保留1个头结点)

{

Teacher*p=PL;

while(p)//逐个删除结点,包括头结点

{

PL=p->next;

deletep;

p=PL;

}

PL=NULL;

}

voidTeacher_Manager:

:

Add()//增加职工

{

cout<<"******增加职工******"<

//查找尾结点

Teacher*p=PL;

while(p->next)

p=p->next;

intch;

cout<<"输入职工分类码(0:

助教,1:

讲师,2:

副教授,3:

教授,4:

行证人员,5:

讲师兼行政管理人员)"<

cin>>ch;

//创建新结点,录入数据,连接到链表

Teacher*pt;

switch(ch)

{

case0:

pt=newAssistant;pt->Input();

p->next=pt;

break;

case1:

pt=newLecturer;pt->Input();

p->next=pt;

break;

case2:

pt=newAssociate_professor;pt->Input();

p->next=pt;

break;

case3:

pt=newProfessor;pt->Input();

p->next=pt;

break;

case4:

pt=newAdministrative_staff;pt->Input();

p->next=pt;

break;

case5:

pt=newLecturer_staff;pt->Input();

p->next=pt;

break;

default:

cout<<"请正确输入数据!

"<

}

}

//查找职工结点(返回1-找到,0-未找到.结点指针由p1返回,p2为前看指针)

intTeacher_Manager:

:

Find(intID,Teacher**p1,Teacher**p2)

{

*p1=PL->next;

*p2=PL;

while(*p1)

{

if((*p1)->num==ID)

break;//找到

else

{

*p2=*p1;//继续查找

*p1=(*p1)->next;

}

}

return*p1?

1:

0;

}

voidTeacher_Manager:

:

Delete()//删除职工

{

cout<<"******删除职工******"<

intnum;

Teacher*p1,*p2;

cout<<"编号:

";cin>>num;

if(!

Find(num,&p1,&p2))

{

cout<<"指定的人员没有找到!

\n";

}

else

{

p2->next=p1->next;//连接

deletep1;

cout<<"正确删除!

\n";

}

}

voidTeacher_Manager:

:

Modify()//修改职工

{

cout<<"******修改职工******\n"<

intnum;

Teacher*p1,*p2;

cout<<"编号:

";cin>>num;

if(!

Find(num,&p1,&p2))

{

cout<<"指定的人员没有找到!

\n";

}

else

{

p1->Output();//输出原来的职工信息(做提示)

p1->Input();//输入新的职工信息(更新)

cout<<"修改完成!

\n";

}

}

voidTeacher_Manager:

:

Print()//输出职工信息

{

cout<<"******职工信息表******"<

cout<<"编号姓名工龄岗位代号课时(上班)收入情况\n";

Teacher*p=PL->next;

if(!

p)

{

cout<<"无职工记录!

\n";

return;

}

while(p)//遍历链表,输出职工信息

{

p->Output();

p=p->next;

}

}

voidTeacher_Manager:

:

Ave_salary()

{

doublea=0.0;

intb=0;

cout<<"\n**职工平均工资**\n";

Teacher*p=PL->next;

if(!

p)

{

cout<<"无职工记录!

\n";

return;

}

while(p)//遍历链表,输出职工信息

{

a=a+p->incoming();

p=p->next;

b++;

}

cout<<""<<(double)a/b<

}

voidTeacher_Manager:

:

Save()//职工信息存盘

{

ofstreamf("Teacher.txt",ios:

:

out);//打开文件,f是对象

//遍历输出至文件

Teacher*p=PL->next;

while(p)

{

p->Output(f);

p=p->next;

}

f.close();//关闭文件

cout<<"职工信息已经保存在Teacher.txt.\n";

}

voidmain()

{

intt;//变量用于功能的选择

Teacher_Managerstaff;//定义职工管理的对象

//显示主菜单,接受选择,并分支调用大学类的相应功能的成员函数

while

(1)

{

system("pause");//暂停

system("cls");//清除

cout<<"\n";

cout<<"**********"<

cout<<"*欢迎使用高校教师工资管理系统!

*"<

cout<<"**********"<

cout<<""<

cout<<""<

cout<<""<

cout<<"您将使用如下功能:

"<

cout<<"**********"<

cout<<"**1:

增加职工**"<

cout<<"**2:

删除职工**"<

cout<<"**3:

修改职工**"<

cout<<"**4:

输出职工(工资)**"<

cout<<"**5:

数据存盘**"<

cout<<"**6:

计算平均工资**"<

cout<<"**:

7:

结束**"<

cout<<"**********"<

cout<<"****请输入相应功能数字(1-7):

****"<

cin>>t;

system("cls");

switch(t)

{

case1:

staff.Add();break;

case2:

staff.Delete();break;

case3:

staff.Modify();break;

case4:

staff.Print();break;

case5:

staff.Save();break;

case6:

staff.Ave_salary();break;

case7:

cout<<"已结束!

按任意键退出系统!

"<

default:

cout<<"输入数无对应功能,请再次输入!

"<

}

}

}

//注:

以上代码在vc++6.0编译环境能正确运行

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 人文社科 > 视频讲堂

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1