I need this with shell linux, thank you. Submission Demonstrate your script exec
ID: 3701754 • Letter: I
Question
I need this with shell linux, thank you.
Submission
Demonstrate your script execution on your laptop to the professor during your scheduled lab periods and submit the completed lab on BlackBoard before due date.
Procedure
Write the following script using your Linux virtual machine. You must use vim as the editor.
The first line of your script file should force the use of the bash shell as the command interpreter. Your script file should be properly commented.
In this assignment, you will create a script called mygrade that will calculate and then display the letter grade. Use only integers for grade calculations.
1. Get user inputs of the following grades:
Assignments 40%
Test1 15%
Test2 15%
Final exam 30%
Note: To avoid decimal places in calculations, you may prompt the user to input an integer
percentage number for each of the items listed above. You don't have to handle
invalid input.
2. Calculate the number grade by adding up the four grades input by user
3. Convert the number grade to letter grade using the table below:
(hint: use “Multilevel if-then-else” or case statement)
Number Grade Letter Grade
90 - 100 A+
85 - 89 A
80 - 84 A-
77 - 79 B+
73 - 76 B
70 - 72 B-
67 - 69 C+
63 - 66 C
60 - 62 C-
57 - 59 D+
53 - 56 D
50 - 52 D-
0 - 49 F
userl@localhost:-$./mygrade Enter assignment mark (8 to 40): 25 Enter Testi mark (? to 15): 8 Enter Test2 mark (1 to 15) 10 Enter Final Exam mark (1 to 30): 24 Your final grade is C+ userldloca thost:-$Explanation / Answer
Please find my implementation.
Please let me know in case of any issue:
#!/bin/sh
echo "Enter assignment mark (0 to 40):"
read sub1
echo "Enter Test1 mark (0 to 15):"
read sub2
echo "Enter Test2 mark (0 to 15):"
read sub3
echo "Enter Final Exam Mark(1 to 30):"
read final
sum1=`expr $sub1 + $sub2 + $sub3 + $final`
echo "Sum of 4 subjects are: " $sum1
if [ $sum1 -lt 100 -a $sum1 -ge 90 ]
then
echo "A+"
elif[ $sum1 -lt 89 -a $sum1 -ge 85 ]
then
echo "A"
elif[ $sum1 -lt 84 -a $sum1 -ge 80 ]
then
echo "A-"
elif[ $sum1 -lt 79 -a $sum1 -ge 77 ]
then
echo "B+"
elif[ $sum1 -lt 72 -a $sum1 -ge 70]
then
echo "B"
elif[ $sum1 -lt 69 -a $sum1 -ge 67 ]
then
echo "C+"
elif[ $sum1 -lt 66 -a $sum1 -ge 63 ]
then
echo "C"
elif[ $sum1 -lt 62 -a $sum1 -ge 60]
then
echo "C-"
elif[ $sum1 -lt 59 -a $sum1 -ge 57]
then
echo "D+"
elif[ $sum1 -lt 56 -a $sum1 -ge 53 ]
then
echo "D"
elif[ $sum1 -lt 52 -a $sum1 -ge 50 ]
then
echo "D-"
else
echo "F"
fi
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.