• 嵌入式操作系统--成绩统计管理系统


    题目:学生成绩统计管理系统

    一  实训任务

    以VM ware虚拟机软件和Ubuntu12.04操作系统为平台,使用shell脚本编写程序,实现对学生成绩的统计计算等功能。要求使用linux shell编写程序脚本(Bash风格),并提供友好的的交互界面。

    二  实训要求

    1. 基本功能要求

    按照题目要求完成程序源码编写、调试及关键代码注释。

      1. 以文本的形式存储各门功课成绩,生成成绩统计表
      2. 实现成绩的计算、统计、排序、查询等功能
      3. 能够以管理员身份对成绩进行管理

    2、扩展功能要求

      1. 可以统计不同成绩段的人数,相同成绩的人数
      2. 扩展其它功能,如界面的改进、增加提示信息等。

    三  实训原理

     

    1 参考系统框图

    四  实训步骤(根据实际情况修改

    1、根据设计任务要求进行功能分析,画出设计流程图;

    2、参阅相关资料,进行模块设计;

    3、编写shell脚本,完成功能模块;

    4、调试脚本程序,修改错误,测试功能,实现任务要求;

    6、撰写实训报告(包括设计与调试的全过程,附上有关资料、shell脚本代码,心得体会)。

    部分程序:

    #!/bin/bash
    #颜色显示
    colour ()
    {
        #格式为背景:前景m,主要实现屏幕颜色显示
    case $1 in 
        white_black ) #背景为白色,前景为黑色
            echo -e "\033[47;30m"
            ;;
        green_white ) #背景为绿色,前景为白色
            echo -e "\033[42;37m"
            ;;
        black_green ) #背景为黑色,前景为绿色
            echo -e "\033[40;32m"
            ;;
        black_cyan ) #背景为黑色,前景为青色
            echo -e "\033[40;36m"
            ;;
        black_blue ) #背景为黑色,前景为蓝色
            echo -e "\033[40;34m"
            ;;
        red_yellow ) #背景为红色,前景为黄色
            echo -e "\033[41;33m"
            ;;
        yellow_blue ) #背景为黄色,前景为蓝色
            echo -e "\033[43;34m"
            ;;
    esac
    }
    #添加
    Student_add()
    {
        clear
        colour black_green
        if test -f Student.txt
        then
            echo -e "请输入学生学号:\c"
        read xuehao
        echo -e "请输入学生姓名:\c"
        read name
        echo -e "请输入语文成绩:\c"
        read Chinese
        echo -e "请输入数学成绩:\c"
        read Math
        echo -e "请输入英语成绩:\c"
        read English
        sum=`expr $Chinese "+" $Math "+" $English`
            ave=`expr $sum "/" 3`
        if [ $ave -ge "90" -a $ave -le "100" ];then
        echo "学号$xuehao $name 同学的语文,数学,英语成绩,总成绩,平均分,成绩等级为.$Chinese.$Math.$English.$sum.$ave.A!" >> Student.txt
        elif [ $ave -ge "80" -a $ave -lt "90" ];then
        echo "学号$xuehao $name 同学的语文,数学,英语成绩,总成绩,平均分,成绩等级为.$Chinese.$Math.$English.$sum.$ave.B!" >> Student.txt
        elif [ $ave -ge "70" -a $ave -lt "80" ];then
        echo "学号$xuehao $name 同学的语文,数学,英语成绩,总成绩,平均分,成绩等级为.$Chinese.$Math.$English.$sum.$ave.C!" >> Student.txt
            elif [ $ave -ge "60" -a $ave -lt "70" ];then
        echo "学号$xuehao $name 同学的语文,数学,英语成绩,总成绩,平均分,成绩等级为.$Chinese.$Math.$English.$sum.$ave.D!" >> Student.txt
        else
        echo "学号$xuehao $name 同学的语文,数学,英语成绩,总成绩,平均分,成绩等级为.$Chinese.$Math.$English.$sum.$ave.E!" >> Student.txt
        echo "添加成功"
        fi
        sleep 1
        else
        echo "成绩文件不存在!"
        echo "正在创建!"
        touch Student.txt
        sleep 1
        echo "成绩文件创建成功!"
        sleep 1
        fi

    }


    #查询
    Student_refer()
    {
        clear
        colour yellow_blue
        # 如果无成绩文件时
        if [ ! -f Student.txt ]; then
            echo "5没有成绩文件请先添加!"
        else
        echo -e " 请输入你要查找的学号:\c"
        read xuehao
        echo -e " 请输入你要查找的名字:\c"
        read name
        # 没有输入名字查询时候
        if [ -z "$name" ]; then
            echo "你没有输入名字!"
            echo -e "请输入你要查找的名字:\c"
        else
        grep "$name" Student.txt 
        case "$?" in
            1 ) echo "该同学成绩尚未录入系统!"
                ;;
        esac
        fi
        fi
    }


    #排序
    Student_sort()
    {
        clear
        colour black_cyan    
        # 如果无成绩文件时
        if [ ! -f Student.txt ]; then
            echo "没有成绩文件请先添加!"
        else    
        echo "排序方式:1.按学号排序;2.按总成绩排序;3.按平均分排序;"
        echo -e "请选择你想要的排序方式:\c"
        read G_sort
        case $G_sort in
         1)
             sort -n  Student.txt
             ;;
        2)
        sort -n -r -t. -k 5 Student.txt
        ;;
             3)
        sort -n -r -t. -k 6 Student.txt
        ;;
        *)
        echo "选择错误,请重新选择"
        Student_sort
        ;;
        esac
        fi
    }


    #统计
    Student_statistics()
    {
        clear    
        colour yellow_blue
        # 如果无成绩文件时
        if [ ! -f Student.txt ]; then
            echo "没有成绩文件请先添加!"
        else    
        for((i=0;i<5;i++))
        do    
        echo  "请输入你想统计的成绩等级人数:"    
        read number    
        grep "$number" Student.txt | wc -l
        done
        fi
    }

    #查看成绩
    Student_display()
    {
        clear    
        colour black_blue
        # 如果无成绩文件时
        if [ ! -f Student.txt ]; then
            echo "没有成绩文件请先添加!"
        else    
        cat Student.txt
        fi
    }

    #删除
    Student_delete()
    {
        clear
        colour green_white
        if [ ! -f Student.txt ]; then
            echo "没有成绩文件请先添加!"
        else    
        echo -e "请输入你要查找的名字\c"
        read name
        
            cp Student.txt Studentfu.txt
            grep "$name" Studentfu.txt > /dev/null
            if [ $? != 0 ]; then
                echo "没有该同学成绩!"
            else
                # -v 表示 not
                grep -v "$name" Studentfu.txt > Student.txt
                echo "删除成功!"
            fi
            rm -rf Studentfu.txt
        fi
    }

    #退出
    Quit()
    {
        clear    
        exit
    }


    clear
    while :
    do
    colour black_green
    echo "    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^      "
    echo "                                                                         "
    echo "                               请选择你的身份:                          "
    echo "                                  1.老师                                 "
    echo "                                  2.学生                                 "
    echo "                                  0.退出系统                             "
    echo "                                                                         " 
    echo "请输入你的选择:                                                          "
    read choose1
    clear
    case $choose1 in
    1)
    echo -e "请输入管理员密码:\c"
    read password
    if [ $password = 123456 ];
    then
    clear
    while :
    do
    colour white_black
    echo "  &———————————————————————————————————————————————————————————————&  "
    echo "                         " 成绩统计系统"                             "
    echo "*———————————————————————————————————————————————————————————————————*"
    echo "                         老师您好,请选择                             "
    echo "                           1.成绩添加                                "
    echo "                           2.成绩查询                                "
    echo "                           3.成绩排序                                "
    echo "                           4.成绩统计                                "
    echo "                           5.删除同学成绩                            "
    echo "                           6.查看全班成绩                            "
    echo "                           0.退出系统                                "
    echo "*————————————————————

    资料包括:

     

    需要完整的资料可在我的资源里下载,也可以加入我的纷传圈子,里面有资源压缩包的百度网盘下载地址及提取码。

    纷传点击用微信打开即可,过程有点繁琐请见谅。

  • 相关阅读:
    OCCT示例学习笔记3--Modeling项目
    词法分析基础
    shell之函数和数组(案例分析)
    用户身份标识与账号体系实践
    Bootstrap框架
    Cross-validation: evaluating estimator performance
    爬虫 | 正则、Xpath、BeautifulSoup示例学习
    2023NOIP游寄
    为chrome浏览器单独设置代理服务器
    threehit漏洞复现以及防御
  • 原文地址:https://blog.csdn.net/qq_63964231/article/details/127722101