#!/bin/sh
mycode() {
read -p “Enter the first number: ” num1
read -p “Enter the second number: ” num2
}
clear
echo “———————————-“
echo “Welcome to Arithmetic Calculator”
echo “———————————-“
echo -e “[a] Addition\n[b] Subtraction\n[c] Multiplication\n[d] Division\n”
while true; do
read -p “Enter your choice: ” choice
case $choice in
[aA])
mycode
result=$((num1 + num2))
echo “The result for your choice is: $result”
;;
[bB])
mycode
result=$((num1 – num2))
echo “The result for your choice is: $result”
;;
[cC])
mycode
result=$((num1 * num2))
echo “The result for your choice is: $result”
;;
[dD])
mycode
if [ $num2 -eq 0 ]; then
echo “Error: Division by zero is not allowed.”
else
result=$((num1 / num2))
echo “The result for your choice is: $result”
fi
;;
*)
echo “Wrong choice. Please choose a valid option.”
;;
esac
read -p “Do you want to perform another calculation? [Y/N]: ” continue_choice
case $continue_choice in
[nN]*)
break
;;
*)
continue
;;
esac
done