below is bash script for a calculator other operations work fine, but I cannot m
ID: 3695402 • Letter: B
Question
below is bash script for a calculator other operations work fine, but I cannot make the multiply work...i tried to use * instead * but to no avail, please help
#!/bin/sh
input="yes"
while [ $input = "yes" ]
do
echo “Enter a Number”
read num1
echo “Enter desired operation +,-,/,*”
read operation
echo “Enter another number”
read num2
result=`expr $num1 "$operation" $num2`
if [ $operation = '+' ]
then
echo The sum of $num1 and $num2 is $result
elif [ $operation = '-' ]
then
echo The difference of $num1 and $num2 is $result
elif [ $operation = '*' ]
then
echo The product of $num1 and $num2 is $result
elif [ $operation = '/' -a $num2 = '0' ]
then
echo The division by $num2 occured and it is invalid
elif [ $operation = '/' ]
then
echo The quotient of $num1 and $num2 is $result
fi
echo "Do you want to calculate again(yes/no):"
read input
echo "Thank you for using this program"
done
Explanation / Answer
--------------------------------
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.