#!/bin/zsh
echo "enter quiz1 score:"
read quiz1
echo "enter quiz2 score:"
read quiz2
echo "enter seatwork score:"
read seatwork
echo "enter exam score:"
read exam
echo "enter lab1 score:"
read lab1
echo "enter lab2 score:"
read lab2
echo "enter lab3 score:"
read lab3
quiz1total=$((quiz1/20))
quiz2total=$((quiz2/30))
quiztotal=$(($quiz1total+$quiz2total))
quizaverage=$(($quiztotal*.20))
examtotal=$(($exam/50))
examaverage=$(($examtotal*.40))
seatworktotal=$((%seatwork/20))
seatworkaverage=$((seatworktotal*.20))
labtotal=$(($lab1+$lab2+$lab3))
labtotals=$(($labtotal/300))
labaverage=$(($labtotals*.20))
midterm=$(($quizaverage+$examaverage+$seatworkaverage+$labaverage))
midtermgrade=$(($midterm*100)
echo "your midterm grade is: $midtermgrade"
答案1
zsh 将其视为/
整数除法。用于.
指示浮点数(例如,在quiz1total=$((quiz1/20))
doquiz1total=$((quiz1/20.))
中)。
$ echo $((1/20))
0
$ echo $((1./20))
0.050000000000000003