UNIX or Linux code

its just different syntax, same ideas behind the code

My code’s at work but it’s similar to boardjnky’s except I used a while for the loop and read to read the numbers in. For some of the questions I used a case (aka switch) statement instead of embedded ifs

I sent them to the OP, if he wants to post them up feel free.

#!/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

ohhhh, i didnt read the questions right I guess. For question 1 I inputted the numbers as arguments to the script instead of user input, oopsy

edit: good code matt danger

:tup: