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

linux language please uestion1 In this case, you will use functions, looping str

ID: 3589903 • Letter: L

Question

linux language please

uestion1 In this case, you will use functions, looping structures, arrays, decision statements, calcu- lations, and other commands necessary to complete the following tasks: 1. Use an array to hold a student record with a name and three grades, for example: "Maude Tedders":100:88:90 2. Use the necessary commands to cut the fields into the name and grades fields 3. Use another array to contain the three grades. For example: Grade[ 1]-necessary statements to get the first grade Grade[ 2]-necessary statements to get the second grade Grade [3]=necessary statements to get the third grade 4. Take a numeric average of the three grades. 5. Convert the numeric average to a letter grade using this scale: A is 90 to 100 B is 80 to 89 C is 70 to 79 D is 65 to 69 F is 0 to 64 6. For each student record, display the student name, numeric average, and letter grade. 7. You must implement at least one function within the script. Create a file that contains at least five student records. Make them up. Provide the program output to demonstrate that your script works

Explanation / Answer

I am attaching two files. One of them contains the data and another has shell script.

=[myScript.sh]==============

#!/bin/sh

myfunc()
{
avgMarks=`echo "$@"| awk '{print ($1+$2+$3)/3}'`
grade=`echo "$avgMarks"| awk '{if($1>=90) print "A"; else if($1>=80) print "B"; else if($1>=70) print "C"; else if($1>=65) print "D"; else print "F" }'`
}


while read -r line
do
    avgMarks=0
    grade='A'
    studName=`echo $line | awk 'BEGIN{FS=":"}{print $1}'`
    marks=`echo $line | awk 'BEGIN{FS=":"}{print $2,$3,$4}'`  
    myfunc $marks
    echo "Name: "$studName" Average Marks: "$avgMarks " Grade: "$grade
done < "studMarks.txt"

==[studMarks.txt]=================

Maude Tedders: 100:88:90
Maude Tedders2: 90:96:75
Maude Tedders3: 50:38:70
Maude Tedders4: 50:86:63
Maude Tedders5: 89:45:87