Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

linux coding Write a Bash shell script results.sh that will determine if partici

ID: 3749871 • Letter: L

Question

linux coding

Write a Bash shell script results.sh that will determine if participants in some competition made it to the finals. For each participant, enter the name and scores from 3 judges ranging from 1 to 10. The script calculates the average score. For each participant the following information should be displayed: the name, individual scores from judges, an average score and the final result: either the message “Good luck tomorrow” if the average score is greater than 7.5, or “Better luck next time” otherwise.

Explanation / Answer

#!/bin/sh

#Numbers of participants
echo "Enter the total number of participants: "
read n
#starting loop for each participant
while [ $n -gt 0 ]
do
#Tanking inputs
echo "Enter name: "
read name
echo "Enter the 1st judge score: "
read s1
echo "Enter the 2nd judge score: "
read s2
echo "Enter the 3rd judge score: "
read s3
#Caculating sum
m=3
sum=`expr $s1 + $s2 + $s3`

#printing name and scores
echo "Name is $name"
echo "Judges scores are: $s1 $s2 $s3 "
echo "Average is: "

#Calculating average
avg=`echo "$sum / $m" | bc -l`

#Printing average
printf '%0.3f' "$avg"

echo
th=7.5

if [ 1 -eq "$(echo "${avg} > ${th}" | bc)" ]
then
echo "Good luck tomorrow".
else
echo "Better luck next time"
fi
# decrement count of n
n=`expr $n - 1`
done