#### Sum many numbers

suffix()
{
	# Let's be quite pedantic, and append the proper suffix!  ;^>
	th="th"
	let digit=$count%10
	if [ $digit = 1 ]; then th="st"; fi
	if [ $digit = 2 ]; then th="nd"; fi
	if [ $digit = 3 ]; then th="rd"; fi
	if [ $count -gt 10 ] && [ $count -lt 20 ]; then th="th"; fi
}



total=0
count=0

echo "#### Sum many positive numbers. ####"
echo -n "How many numbers?	"
read many

while [ $count -lt $many ]
do

	let count=count+1
	th="th"
	suffix $count
	echo -n "$count$th number:	"
	read n
	while [ $n -eq 0 ]
	do
		echo "Zero is not allowed!"
		echo -n "Try again!"
		read n
	done
	# (Nested loop.)

	let total=$total+$n
	echo "($total)"

done

echo "The grand total is:	$total"
echo "# Thank you for using my sum-th script. #"
exit 0
