#!/bin/bash


#bash函式以及返回值的注意事項
function showgrade(){
    if [ ! -z "$1" ];then
        echo "Your grade is $1"
    else
        echo "Invalid call $FUNCNAME"
    fi
}


#學生成績分類
echo "Please input a integer(0-100)"
read score


if [ "$score" -lt 0 -o "$score" -gt 100 ];then
    echo "The score what you input is not a valid score."
    #bash的最大返回值是255,==256則返回0,
    #如果返回值是1000則,實際返回值是1000%256 = 232
    exit 100
else
    if [ "$score" -ge 90 ];then
        showgrade "A"
    else
        if [ "$score" -ge 80 ];then
            showgrade "B"
        else
            if [ "$score" -ge 70 ];then
                showgrade "C"
            else
                if [ "$score" -ge 60 ];then
                    showgrade "D"
                fi
            fi
        fi
    fi
fi