Instructions:
- Create a new page in your portfolio and name it âLab 6â with âEMT 2390Lâ as its parent.
- Create one script that will ask the user the following data:
- Name
- Course Code
- Grade Percentage
- After getting the data, use the grading scale in the syllabus, and display the appropriate message
e.g. âHello John Doe. Your grade for EMT 2390L is Aâ
- Create another script that will ask the user for an integer n, and displays the sum of the first n numbers
e.g. input = 4; output = 10 (i.e. 4+3+2+1)
- In your portfolio post the following for each script
- An paragraph summarizing your script
- Your scriptâs code
- Screenshots of your script running
PART ONE Â SCRIPT:
PART ONE SCRIPT CODE:
#!/bin/bash
echo “Enter your name”
read name
echo “Enter your course code”
read course
echo “What is your grade percentage”
read grade
while [ $grade -gt 100 ]; do
echo “Enter a valid number”
read grade
done
if [ $grade -ge 93 ]; then
echo “Hello $name, your grade for the course $course is A”
elif [ $grade -ge 90 ]; then
echo “Hello $name, your grade for the course $course is A-”
elif [ $grade -ge 87 ]; then
echo “Hello $name, your grade for the course $course is B+”
elif [ $grade -ge 83 ]; then
echo “Hello $name, your grade for the course $course is B”
elif [ $grade -ge 80 ]; then
echo “Hello $name, your grade for the course $course is B-”
elif [ $grade -ge 77 ]; then
echo “Hello $name, your grade for the course $course is C+”
elif [ $grade -ge 70 ]; then
echo “Hello $name, your grade for the course $course is C”
elif [ $grade -ge 60 ]; then
echo “Hello $name, your grade for the course $course is D”
elif [ $grade -ge 0]; then
echo “Hello $name, your grade for the course $course is F”
fiPART ONE SCRIPT SUMMARY:
This script is one of a kind. I created it to read a person grade by first entering your name, course, and your percentage which you will be receiving from your professor in class. For example, first need to active the program by pressing ./grade, then the program will run and first ask you to enter your name “Devin” , second it will say enter your course name “EMT2390L” and final it will ask for grading percentage ” 94″. Then the program will read and say ” Hello Devin your grade for the course EMT2390L is A”. This program was created in the VI terminal where it was typed and tested. I also added the feature if a person enter a number more then 100. The error message would come up and say “enter a valid number”. In writing this program I have use the “IF command case” to help entering the different grading system. Â Also, use the shebang to started writing my script because that’s like a starting for the shell.
PART TWO SCRIPT CODE:
#!/bin/bash
x=0
echo=”Enter a interger number”
read number
for ((i=0; i<=$number; i=i+1)); do
x=$(($x + $i))
done
echo “Sum of 0 to $number is : $x”PART TWO SCRIPT SUMMARY:
In this script it was kind of difficult but it took sometimes to figure it out. This second script was close to one of the number script we did it in class, however it was a little different. As you can see in the coding we started off using the shebang and then right into the shell writing. I use X as a valuable so where x is always 0. Then I use echo to enter the a integer number. Where I had to use read so the system would read the number. Afterwards I use the same formula we used in class to do the coding while using the dollar sign to help read that number. When i finish I then end the system then put done. Echo is used to read the sum of 0 to a number of X value. When I test this program out everything run well and didn’t give me a problem. It would how it suppose to work how it was written.