UNIX or Linux code

#!/bin/ksh
# Question 1
COUNT=0
while read NUM; do
        # Set initials
	if [ $COUNT -eq 0 ]; then
		HIGHEST=$NUM
		LOWEST=$NUM
		SUM=$NUM
	fi
	# If 999 is entered, break out
	if [ $NUM -eq 999 ]; then
		break
	else
		# See if inputted number is the highest number
		if [ $NUM -gt $HIGHEST ]; then
			HIGHEST=$NUM
		fi

		# See if inputted number is the lowest number
		if [ $NUM -lt $LOWEST ]; then
			LOWEST=$NUM;
		fi
		# Calculate sum
		SUM=$(($SUM+$NUM))
	fi
	COUNT=$(($COUNT+1))
done
AVERAGE=$(($SUM/$COUNT))
echo "Highest number: $HIGHEST"
echo "Lowest number: $LOWEST"
echo "Sum of the numbers: $SUM"
echo "Average of the numbers: $AVERAGE"
#!/bin/ksh
# Question 2
RAN=$((RANDOM%60))
COUNTER=1
echo -n "I've guessed a number between 0-60, what is it? "
while read GUESS; do
	if [ $GUESS -eq $RAN ]; then
		break;
	else
		echo
		if [ $GUESS -lt $RAN ]; then
			echo -n "Nope, try a higher number: "
		else
			echo -n "Nope, try a lower number: "
		fi	
	fi
	COUNTER=$((COUNTER+1))
done
echo; echo "Yep, good job! It took you $COUNTER tries to guess correctly."
#!/bin/ksh
# Question 3
echo -n "Enter a number: "; read NUM
echo -n "Enter 1 to count up to $NUM and 2 to count down to 0: "; read CHOICE
case $CHOICE in
	1)	COUNTER=0
		while [ $COUNTER -le $NUM ]; do
			echo $COUNTER
			COUNTER=$(($COUNTER+1))
		done ;;

	2)	while [ $NUM -ge 0 ]; do
			echo $NUM;
			NUM=$(($NUM-1))
		done ;;
esac