7

Making a calculator that can loop - Bash

view full story
linux-howto

http://stackoverflow.com – I am trying to make a calculator. The user Enters number 1, chooses and operation, enters number 2, then chooses another operation or for the answer to be displayed. eg. 1 + 1 = or 1 + 1 + 2 + 1 = Both of these should be possible. read -p "what's the first number? " n1 PS3="what's the operation? " select ans in add subtract multiply divide equals; do case $ans in add) op='+' ; break ;; subtract) op='-' ; break ;; multiply) op='*' ; break ;; divide) op='/' ; break ;; equals) op= *) echo "invalid response" ;; esac done read -p "what's the second number? " n2 ans=$(ec (HowTos)