Lab 6: part 1
#!/bin/bash
echo “enter your name”
read name
echo “enter enter course”
read course
echo “what is your grade percentage”
read grade
while [ $grade -gt 100 ]; do
echo “enter a grade less than 100”
read grade
done
if [ $grade -ge 90 ]; then
echo “Hello $name, your grade for the $course is A”
elif [ $grade -ge 80 ]; then
echo “Hello $name, your grade for the $course is B”
elif [ $grade -ge 70 ]; then
echo “Hello $name, your grade for the $course is C”
elif [ $grade -ge 60 ]; then
echo “Hello $name, your grade for the $course is D”
else
echo “Hello $name, your grade for the $course is F”
fi
The program is designed to collect student’s course number name and grade percentage. The compiler then prints out the name and course and goes through the if… then stage to convert the percentage into the letter grade. At the end all three results are printed.
Lab 6: part 2
#!/bin/bash
echo “enter the number”
read n
for (( x=o; n>=0; –n )); do
x=$((x+n))
done
echo “The result is: $x”
The program is designed to collect a number and the compiler then sends the number through a for loop. That specific number is then being added to the lesser number until it reaches zero. At the end the total result is printed.