So I am writing a program on linux terminal and my program has two parts. The first part is division, the second part is calculating the MOD for some numbers. The way to quit the first part is to put 999 in either of the inputs to divide.
My problem is that the user must put a second number even if the user input 999 as a first input. I was wondering if these is a thing like in windows where you can do goto :someOtherLocation in linux. This is the code:
echo "Enter the number to divide (dividend) (enter 999 to quit):"
read numberOne
[IF NUMBERONE = 999, JUMP TO SECONDPART]
echo "Enter the number to divide (divisor) (enter 999 to quit):"
read numberTwo
while [ "$numberOne" -ne '999' ] && [ "$numberTwo" -ne '999' ]
do
while [ "$numberTwo" -eq 0 ]
do
echo "You cannot divide by 0, please enter another number:"
read numberTwo
done
RESULT=$(echo "$numberOne/$numberTwo" | bc -l)
echo $numberOne / $numberTwo = $RESULT
echo $numberOne / $numberTwo = $RESULT >> results.txt
echo "Enter the number to divide (dividend) (enter 999 to quit):"
read numberOne
echo "Enter the number to divide (divisor) (enter 999 to quit):"
read numberTwo
done
SECONDPART
counter=1
totalCount=0
temporal=0
while [ "$counter" -lt '101' ]
do
temporal=$( expr $counter % 5)
echo $counter MOD 5 = $temporal
echo $counter MOD 5 = $temporal >> results.txt
totalCount=$(echo "$totalCount+$temporal" | bc -l)
counter=$(echo "$counter+1" | bc -l)
done
average=$(echo "$totalCount/100" | bc -l)
echo The average of all the MODs is $average >> results.txt
So as seen above, I would like to jump from the input straight to the secondpart, if the input is 999.