求问一道C++题目。求大神解答。。带注释就更好了,能讲一下思路也好。。

 学校主要有四类人员:从事管理的行政人员、只从事教学的纯教师、从事行政工作的教师(既有行政职务,又从事教学)和工人,现在要存储这些人员的姓名、编号、级别、当月薪水,计算月薪并显示全部信息。 人员编号基数为10000,每输入一个职工信息编号加1。 月薪的计算方法如下: 行政人员:固定月薪900*级别+奖金(850) 只从事教学的纯教师:固定月薪700*级别+课时*课时费(40/每课时) 从事行政工作的教师:固定月薪700*级别+课时*课时费(40/每课时)+奖金(650) 工人:固定月薪400*级别+特殊补(天数*30/天)。

设计要求:

       根据需求陈述,设计一个基类Employee,派生出类Teacher(纯教师类)、Manager(管理类)和Worker(工人类),再由纯教师类和管理类派生出Teach_Manager(从事行政工作的教师)类。

基类定义如下:

//employee.h

classEmployee

{

       protected:

                            char*name;  //姓名

int EmpNO; //个人编号

int grade;   //级别

float monthPay;  //固定月薪

float accumpay;  //月薪总和

static int employeeNO; //现在职员编号

       public:

              Employee();//构造函数

              ~employee();//析构函数

              void pay(); //计算月薪函数

              void Promote(int);//设定职级函数

              void DispalyStatus();//显示信息函数

};

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
#include #include #include #include #include #define MAX_NAME 20 #define NULL 0 struct course { char course_name[MAX_NAME]; int class_num; int ch_per; int ex_per; struct course *next; }; struct teacher { char teacher_num[MAX_NAME]; char teacher_name[MAX_NAME]; struct teacher *next; struct course *chead; struct course *ctail; }; struct teacher *thead,*ttail,*found; //*********************************************************************** //主菜单 void menu() { system("cls"); printf("*************************************\n"); printf("* 1.输入教师信息 *\n"); printf("* 2.插入授课信息 *\n"); printf("* 3.工作量计算与显示 *\n"); printf("* 4.退出 *\n"); printf("*************************************\n"); printf("请输入要操作的序号:"); } int isExist(char number[]) //判断输入的教师号是否已经存在 { struct teacher *p; p=thead; while(p!=NULL && (strcmp(p->teacher_num,number)!=0)) p=p->next; found=p; if(p==NULL) return 0; else return 1; } //************************************************************************ //增加教师教学信息模块 void addIn() { struct teacher *p; struct course *pcourse; char teacher_num[MAX_NAME]; char teacher_name[MAX_NAME]; char course_name[MAX_NAME]; int class_num; int ch_per; int ex_per; while(1) { system("cls"); printf("****************************************************\n"); printf("* 输入教师的信息,以输入教师号为#结束输入 *\n"); printf("****************************************************\n"); printf("输入教师号:"); fflush(stdin); scanf("%s",teacher_num); if(isExist(teacher_num)) { printf("!!!该教师号已经存在,请重新输入。\n按任意键重新输入...\n"); getch(); } else { if(strcmp(teacher_num,"#")==0) { printf("**************************************************\n"); printf("输入结束。按任意键返回主菜单...\n"); getch(); return; } printf("输入教师姓名:");fflush(stdin);scanf("%s",teacher_name); printf("****************************************************\n"); printf("* 输入教师授课信息 *\n"); printf("****************************************************\n"); printf("输入课程名称:");fflush(stdin);scanf("%s",course_name); printf("输入班级数目:");fflush(stdin);scanf("%d",&class_num); printf("输入理论课时:");fflush(stdin);scanf("%d",&ch_per); printf("输入实验课时:");fflush(stdin);scanf("%d",&ex_per); pcourse=(struct course *)malloc(sizeof(struct course)); strcpy(pcourse->course_name,course_name); pcourse->class_num=class_num; pcourse->ch_per=ch_per; pcourse->ex_per=ex_per; pcourse->next=NULL; p=(struct teacher *)malloc(sizeof(struct teacher)); strcpy(p->teacher_num,teacher_num); strcpy(p->teacher_name,teacher_name); p->chead=pcourse; p->ctail=pcourse; if(thead==NULL) { thead=p; ttail=p; } else { ttail->next=p; ttail=p; } ttail->next=NULL; } } } //************************************************************************ //插入教师授课信息模块 void addCourseInfo() { struct course *pcourse; char teacher_num[MAX_NAME]; char course_name[MAX_NAME]; int class_num; int ch_per; int ex_per; system("cls"); if(thead==NULL) { printf("****************************************************\n"); printf("* 当前没有可用的教师信息,按任意键返回主菜单... *\n"); printf("****************************************************\n"); getch(); return; } while(1) { system("cls"); printf("输入教师号:");fflush(stdin);scanf("%s",teacher_num); if(isExist(teacher_num)) break; else { printf("!!!该教师号不存在,请重新输入.\n按任意键重新输入...\n"); getch(); } } printf("****************************************************\n"); printf("* 输入教师授课信息 *\n"); printf("****************************************************\n"); printf("输入课程名称:");fflush(stdin);scanf("%s",course_name); printf("输入班级数目:");fflush(stdin);scanf("%d",&class_num); printf("输入理论课时:");fflush(stdin);scanf("%d",&ch_per); printf("输入实验课时:");fflush(stdin);scanf("%d",&ex_per); pcourse=(struct course *)malloc(sizeof(struct course)); strcpy(pcourse->course_name,course_name); pcourse->class_num=class_num; pcourse->ch_per=ch_per; pcourse->ex_per=ex_per; pcourse->next=NULL; found->ctail->next=pcourse; found->ctail=pcourse; } //************************************************************************ //计算并显示 void calcu() { struct teacher *p; struct course *pcourse; float single_per=0.0; float total_per=0.0; system("cls"); if(thead==NULL) { printf("****************************************************\n"); printf("* 当前没有可用的教师信息,按任意键返回主菜单... *\n"); printf("****************************************************\n"); getch(); return; } p=thead; while(p!=NULL) { total_per=0.0; printf("----------------------------------------------------------------------\n"); printf("教师号:%s\n",p->teacher_num); printf("教师姓名:%s\n",p->teacher_name); printf("----------------------------------------------------------------------\n"); printf("课程名称 班级数目 理论课时 实验课时 单教学任务总课时\n"); printf("----------------------------------------------------------------------\n"); pcourse=p->chead; while(pcourse!=NULL) { single_per=0.0; if(pcourse->class_num==1) single_per=pcourse->ch_per+pcourse->ex_per; if(pcourse->class_num==2) single_per=1.5*(pcourse->ch_per+pcourse->ex_per); if(pcourse->class_num==3) single_per=2.0*(pcourse->ch_per+pcourse->ex_per); if(pcourse->class_num>=4) single_per=2.5*(pcourse->ch_per+pcourse->ex_per); printf("%-10s%-10d%-10d%-10d%-7.3f\n",pcourse->course_name,pcourse->class_num,pcourse->ch_per,pcourse->ex_per,single_per); total_per+=single_per; pcourse=pcourse->next; } printf("----------------------------------------------------------------------\n"); printf("一个学期总的教学工作量:%7.3f\n",total_per); printf("----------------------------------------------------------------------\n\n\n\n"); p=p->next; } printf("\t****************************************************\n"); printf("\t* 已经显示完毕,按任意键返回主菜单... *\n"); printf("\t****************************************************\n"); getch(); } //************************************************************************ //主函数 void main() { int order; while(1) { menu(); fflush(stdin); scanf("%d",&order); switch (order) { case 1:addIn();break; case 2:addCourseInfo();break; case 3:calcu();break; case 4:exit(0);break; default: printf("输入的序号有误,请检查后重新输入...\n"); getch(); break; } } }
1、题描述 某高校有四类员工教师、实验员、行政人员教师兼行政人员共有的信息包括编号、姓名、性别、年龄等。其中教师还包含的信息有所在系部、专业、职称实验员还包含的信息由所在实验室、职务行政人员还包含的信息有政治面貌、职称等。 2、功能要 (1)添加功能程序能够任意添加上述四类人员的记录可提供选择界面供用户选择所要添加的人员类别要员工的编号要唯一如果添加了重复编号的记录时则提示数据添加重复并取消添加。 (2)查询功能可根据编号、姓名等信息对已添加的记录进行查询如果未找到给出相应的提示信息如果找到则显示相应的记录信息。 (3)显示功能可显示当前系统中所有记录每条记录占据一行。 (4)编辑功能可根据查询结果对相应的记录进行修改修改时注意编号的唯一性。 (5)删除功能主要实现对已添加的人员记录进行删除。如果当前系统中没有相应的人员记录则提示“记录为空”并返回操作否则输入要删除的人员的编号或姓名根据所输入的信息删除该人员记录如果没有找到该人员信息则提示相应的记录不存。 (6)统计功能能根据多种参数进行人员的统计。能统计四类人员数量以及总数,统计男、女员工的数量。 (7)保存功能可将当前系统中各类人员记录存入文件中存入方式任意。 (8)读取功能可将保存在文件中的人员信息读入到当前系统中供用户进行使用。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值