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

Write a script in Bourne shell that presents a user with a menu as follows: Add

ID: 3911420 • Letter: W

Question

Write a script in Bourne shell that presents a user with a menu as follows:

Add the numbers (enter a or A)

Subtract the numbers (enter s or S)

Multiply the numbers (enter m or M)

Divide the numbers (enter d or D)

Exit (select e or E)

If the user enters any other character other than the ones mentioned, then print an error saying it is not a choice and ask the user to select again until the correct option is chosen.

Once the operation is done, ask the user if they want to do another operation on the same two integers or do another operation with two different integers or exit. Do accordingly based on the users choice. So until the user does not select the exit option, the user is presented with a menu. Also, when you run the script, provide two integers as command line arguments. The beginning of your script should have an if statement that checks how many arguments are coming in and present a few statements about Usage of the script if the number of arguments is not 2.

Explanation / Answer

#1
echo -n "please enter a number : "
read n
remainder=$(( $n % 2 ))
if [ $remainder -eq 0 ] #remainder is zero
then
echo "$n is even number"
else
echo "$n is odd number"
fi

#2
while [ true ]
do
echo "Are you OK?"
read n
if [ $n = "Y" ] || [ $n = "y" ]; then
echo "Glad to hear it"
break;
elif [ $n = "N" ] || [ $n = "n" ]; then
echo "Sorry that you are not feeling food"
break;
else
echo "Incorrect choice: Enter from Y,y,N,n";
fi
done

#3 : Put it in different file
score=$1
if [ $score -le 100 ] && [ $score -ge 90 ]; then
echo "You got an A";
elif [ $score -lt 90 ] && [ $score -ge 80 ]; then
echo "You got an B";
elif [ $score -lt 80 ] && [ $score -ge 70 ]; then
echo "You got an C";
elif [ $score -lt 70 ] && [ $score -ge 60 ]; then
echo "You got an D";
elif [ $score -lt 60 ] ; then
echo "You failed";
else
echo "Error: Value should be between 0 and 100";
fi

#4
dt=$(date '+%d_%m_%Y_%H_%M_%S');
dt=(${dt//_/ });
for i in {0..5}
do
echo "${dt[$i]}"
done

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