ans='Y'
while [ $ans = 'Y' -o $ans = 'y' ]
do
echo "Enter operand1: "
read op1
echo "Enter operand2: "
read op2
echo "Enter operation: "
echo "+ for addition"
echo "- for subtraction"
echo "* for multiplication"
echo "/ for division"
echo "Enter your choice: "
read op
case $op in
"*")sum=`expr $op1 \* op2`
echo "Product is $sum";;
"+")sum=`expr $op1 + op2`
echo "Sum is $sum";;
"-")sum=`expr $op1 - $op2`
echo "Difference is $sum";;
"/")sum=`expr $op1 / $op2`
echo "Quotient is $sum";;
*)echo "Invalid Entry"
esac
echo "Do you wish to continue:(Y/N):"
read ans
done
--------------------------------------------------------------------------------------------------------------
OUTPUT
Enter operand1:
8
Enter operand2:
4
Enter operation:
+ for addition
- for subtraction
* for multiplication
/ for division
Enter your choice:
/
Quotient is 2
Do you wish to continue:(Y/N):
n
0 comments:
Post a Comment