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

Having trouble devising a script can you please help (Unix sh not Java) Consider

ID: 3735118 • Letter: H

Question

Having trouble devising a script can you please help (Unix sh not Java) Consider the file named data2 as shown below:

Username                            Score

pchen72                                 10

jmaszk                                     5

bvbui                                       13

mtcrowle                                 50

mrchave3 34

This lists usernames and the respective score for each username. Write a script named Lab4B.3.sh that will calculate the average of the scores above and then display the percentage of rows above and below the average.

Explanation / Answer

Following is the shell script:

awk '{ total += $2; count++; total1 = total/count; } {

if ($2 <= total1)

{

print "below Average " $2;

}

else if ($2 >= total1)

{

print "Above Average " $2

}

} END {

print "Average is " total1 }' file1.txt

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote