Calculator [Shell Program]



clear


ans=Y


while [ "$ans" = "Y" ]


do


clear


echo "*****MENU*****"


echo "1.ADD"


echo "2.SUBSTRACT"


echo "3.MULTIPLY"


echo "4.DIVIDE"


echo "5.MOD"


echo "0.EXIT"


echo "Enter your
Choice"


read ch


case $ch in


1) echo "Enter the
1st number"


  
read num1


  
echo "Enter the 2nd number"


  
read num2


  
s
=`expr $num1 + $num2`


  
echo "The result:"$s;;


2) echo "Enter the
1st number"


  
read num1


  
echo "Enter the 2nd number"


  
read num2


  
s
=`expr $num1 - $num2`


  
echo "The result:"$s;;


3) echo "Enter the
1st number"


  
read num1


  
echo "Enter the 2nd number"


  
read num2


  
s
=`expr $num1 \* $num2`


  
echo "The result:"$s;;


4) echo "Enter the
1st number"


  
read num1


  
echo "Enter the 2nd number"


  
read num2


  
s
=`expr $num1 / $num2`


  
echo "The result:"$s;;


5) echo "Enter the
1st number"


  
read num1


  
echo "Enter the 2nd number"


  
read num2


  
s
=`expr $num1 % $num2`


  
echo "The result:"$s;;


0) exit;;


*) echo "WRONG
CHOICE"
;;


esac





echo "Do you want
to continue?(Y/N)"


read ans


done





Comments

Popular posts from this blog

Write a Program to Add two 3x3 Matrix using C

C program for Unit Conversion

Write a Program to Add two 5x5 Matrix using C