calculator using shell script

"1.addition" "2.subtraction" "3.multiplication" "4.division" "5.square" "6.squareroot" "7.modular" using shell script
 avatar
Rohit143
sh
4 years ago
1.0 kB
15
Indexable
echo "Enter one no."
read n1
echo "Enter second no."
read n2
echo "1.addition"
echo "2.subtraction"
echo "3.multiplication"
echo "4.division"
echo "5.square"
echo "6.squareroot"
echo "7.modular"
echo ----------------
echo "Enter your choice:"
read ch
echo ----------------
case $ch in
	1)echo "Addition = " `expr $n1 + $n2`;;
	
	2)echo "Subtaction = " `expr $n1 - $n2`;;
	
	3)echo "Multiplication = " `expr $n1 * $n2`;;
	
	4)echo "Division = " `expr $n1 / $n2`;;
	
	5) 
	echo You selected \"Square\"
	echo Enter Number
	read number
	echo ----------------
	echo "Square of $number = " $(( $number * $number ));;
	
	6) 
	echo You selected \"Squareroot\"
	echo Enter Number
	read number
	echo ----------------
	calc=$(echo "sqrt ( $number )" | bc -l) ; 
	echo "Sqaure root of  $number" $calc;;

	7)echo "Modulus = " `expr $n1 % $n2`;; 
	
	*)echo "Invalid Choice";;
	esac
	echo "Do you want to continue ?"
	read i
	case $i in
		"y")sh cal.sh;;
		*)exit 2;;
	esac
	
Editor is loading...