C语言课设--教师评价系统

流程图链接

修改函数:https://www.processon.com/view/link/57d9115ae4b0497022da109c

删除函数:https://www.processon.com/view/link/57d911a1e4b0497022da15b2

插入函数:https://www.processon.com/view/link/57d911bce4b0e78cc001145d

浏览函数:https://www.processon.com/view/link/57d911d4e4b0497022da195c

评价函数:https://www.processon.com/view/link/57d911e4e4b0497022da1a95


三、核心技术的实现说明及相应的程序段

本程序六个自定义函数和一个主函数组成,其中主函数循环调用菜单,菜单函数调用其他函数来实现要求的所有功能。在这些函数当中,插入函数,修改函数,删除函数,浏览函数,评价函数是程序的核心部分,下面分别进行说明。


1、插入函数

插入函数中,首先用户输入的教师编号,该编号不能超出最大范围并且仅当该编号未存在教师信息的情况下,用户才能添加数据。

具体的程序段如下:

void insert(){
    int     _id;
    printf("Please enter teacher information\n");
    printf("id = ");
    scanf("%d",&_id);
    if(_id >  0   &&_id    <   100){
        if(teacher[_id].id  ==  _id){
            printf("Teacher exist\n");
            return;
        }
        else{
            char	_name[20];
            char	_sex[5];
            char	_title[20];
            char	_post[20];
            char	_course[20];
            
            printf("name = ");
            scanf("%s",_name);
            printf("sex = ");
            scanf("%s",_sex);
            printf("title = ");
            scanf("%s",_title);
            printf("post = ");
            scanf("%s",_post);
            printf("course = ");
            scanf("%s",_course);
 
  
            teacher[_id].id       =   _id;
            strcpy(teacher[_id].name,_name);
            strcpy(teacher[_id].sex,_sex);
            strcpy(teacher[_id].title,_title);
            strcpy(teacher[_id].post,_post);
            strcpy(teacher[_id].course,_course);
            printf("Insert successfully\n");
        }
    }
    else{
        printf("Insert failed\n");
    }
 
  
    return;
}

2、修改函数

该函数的核心内容是覆盖之前存在的信息。首先要保证要操作的对象是已存在的教师信息,由用户输入待修改教师信息的教师编号,通过对比验证该教师信息已存在,随后通过教师编号将该教师信息显示出来,用户输入修改后的内容,通过教师编号将欲修改的信息覆盖在原来的信息上。

具体的程序段如下:

void revise(){
    int _id;
    printf("Please enter teacher id\n");
    scanf("%d",&_id);
    if(teacher[_id].id  ==  _id){//教师信息存在
        char	_name[20];
        char	_sex[5];
        char	_title[20];
        char	_post[20];
        char	_course[20];
 
  
        printf("Teacher information is as follows\n");
        printf("id = %d ",teacher[_id].id);
        printf("name = %s ",teacher[_id].name);
        printf("sex = %s ",teacher[_id].sex);
        printf("title = %s ",teacher[_id].title);
        printf("post = %s ",teacher[_id].post);
        printf("course = %s\n",teacher[_id].course);
 
  
        printf("Please revise teacher information\n");
        printf("name = ");
        scanf("%s",_name);
        printf("sex = ");
        scanf("%s",_sex);
        printf("title = ");
        scanf("%s",_title);
        printf("post = ");
        scanf("%s",_post);
        printf("course = ");
        scanf("%s",_course);
 
  
        strcpy(teacher[_id].name,_name);
        strcpy(teacher[_id].sex,_sex);
        strcpy(teacher[_id].title,_title);
        strcpy(teacher[_id].post,_post);
        strcpy(teacher[_id].course,_course);
        printf("Revise successfully\n");
    }
    else{
        printf("Teacher does not exist\n");
    }
    return;
}

3、删除函数

删除函数的核心内容是清空已存的教师信息。首先用户输入待删除的教师编号,当编号存在教师信息时,用函数将已保存教师信息的内容重置为零

具体程序段如下:

void del(){
    int _id;
    printf("Please enter teacher id\n");
    scanf("%d",&_id);
    if(teacher[_id].id  ==  _id){//教师信息存在
        memset(&teacher[_id],0,sizeof(teacher[_id]));
        printf("Delete successfully\n");
    }
    else{
        printf("Teacher does not exist\n");
    }
    return;
}


4、浏览函数

浏览函数中,根据用户输入的编号进行查找,首先编号下存在教师信息,才能显示教师信息。

具体程序段如下:

void browse(){
    int _id;
    printf("Please enter teacher id\n");
    scanf("%d",&_id);
    if(teacher[_id].id  ==  _id){//教师信息存在
        printf("Teacher information is as follows\n");
        printf("id = %d ",teacher[_id].id);
        printf("name = %s ",teacher[_id].name);
        printf("sex = %s ",teacher[_id].sex);
        printf("title = %s ",teacher[_id].title);
        printf("post = %s ",teacher[_id].post);
        printf("course = %s\n",teacher[_id].course);
        printf("score = %d\n",teacher[_id].score);
    }
    else{
        printf("Teacher does not exist\n");
    }
    return;
}

5、评价函数

评价函数主要操作是对教师的评价打分并求和。首先用户输入编号,该编号下存在教师并且教师未被打分时,开始对每项进行打分,用户依次输入相应的分数,通过累加每次输入的分数求和,得到最终得分,并写入教师的评价总分中。

具体程序段如下:

void evaluate(){
    int _id;
    int sum =   0;
    printf("Please enter teacher id\n");
    scanf("%d",&_id);
    if(teacher[_id].id  ==  _id){//教师信息存在
        if(teacher[_id].score   ==  0){
            int _score;
            printf("Each item full marks is 10\n");
            printf("prepare lessons = ");//备课
            scanf("%d",&_score);
            sum +=  _score;
            printf("teaching = ");//授课
            scanf("%d",&_score);
            sum +=  _score;
            printf("style = ");//风格
            scanf("%d",&_score);
            sum +=  _score;
            printf("homework = ");//作业
            scanf("%d",&_score);
            sum +=  _score;
            printf("practice = ");//练习
            scanf("%d",&_score);
            sum +=  _score;
            printf("discipline = ");//纪律
            scanf("%d",&_score);
            sum +=  _score;
            printf("vivid = ");//生动
            scanf("%d",&_score);
            sum +=  _score;
            printf("answering question = ");//答疑
            scanf("%d",&_score);
            sum +=  _score;
            printf("content = ");//内容
            scanf("%d",&_score);
            sum +=  _score;
            printf("punctual = ");//准时
            scanf("%d",&_score);
            sum +=  _score;
 
  
            teacher[_id].score  =   sum;
        }
        else{
            printf("Teacher has been evaluated\n");
            return;
        }
 
  
        printf("Teacher evaluation score is %d\n",sum);
    }
    else{
        printf("Teacher does not exist\n");
    }
    return;
}

你可能感兴趣的:(C语言课设,C语言课设)