### calculator problem

can someone to help me with this calculator? i want the user to be able the press A for add and B for subtract etc. how would i do that? am using BASH

HERE IS MY CODES SO FAR:

echo "choose from the menu :
(B) Subtract
(C) Multiply
(D) Divide
(E) Modulus
(F) Exponentiation

echo "Choose a letter between A-F or G to exit"
read -p "Enter a operand letter : " letter
read -p "Enter a second number : " num2

for ((\$letter"="+"];
then
ans=(\$num1 + \$num2);

if else["\$letter"="-"];
then
ans=(\$num1 - \$num2);
Study this snippet of code and complete it:
 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071`` ``````#!/bin/bash clear red='\e[1;31m' lcyan='\e[1;36m' NC='\e[0m' # No Color l="x" while [ \$l != "\$g" ] do echo "----------------" echo "Choose a-g: a...adding ....... e...modulus f...exponentiation g...exit" read -n 1 -p "Enter a letter: " l echo echo "-----------------" case "\$l" in a) echo -en \$lcyan echo "ADDING" echo -en \$NC read -p "Enter two numbers: " n1 n2 echo -en \$red echo -n "\$n1 + \$n2 = " echo \$((\$n1 + \$n2)) echo -en \$NC # For floating numbers must have: # echo "\$n1 + \$n2" | bc -l # e.g.: entering 2.3 and 3.93 will give 6.23 ;; # B/b...D/d e) echo -en \$lcyan echo "MODULUS" echo -en \$NC read -p "Enter two numbers: " n1 n2 echo -en \$red echo -n "\$n1 % \$n2 = " echo \$((\$n1 % \$n2)) echo -en \$NC ;; f) echo -en \$lcyan echo "EXPONENTIATION" echo -en \$NC read -p "Enter two numbers: " n1 n2 echo -en \$red echo -n "\$n1 ^ \$n2 = " echo \$((\$n1**\$n2)) echo -en \$NC ;; g) echo -en \$lcyan echo "EXIT" echo -en \$NC exit ;; esac done exit 0`````` ```---------------- Choose a-g: a...adding ....... e...modulus f...exponentiation g...exit Enter a letter: a ----------------- ADDING Enter two numbers: 2 15 2 + 15 = 17 ---------------- Choose a-g: a...adding ....... e...modulus f...exponentiation g...exit Enter a letter: e ----------------- MODULUS Enter two numbers: 19 7 19 % 7 = 5 ---------------- Choose a-g: a...adding ....... e...modulus f...exponentiation g...exit Enter a letter: f ----------------- EXPONENTIATION Enter two numbers: 3 5 3 ^ 5 = 243 ---------------- Choose a-g: a...adding ....... e...modulus f...exponentiation g...exit Enter a letter: g ----------------- EXIT```

Topic archived. No new replies allowed.