Submitted by: Submitted by jdtony1988
Views: 107
Words: 557
Pages: 3
Category: Business and Industry
Date Submitted: 10/07/2013 08:58 PM
1. #This is the script for the calculator
input="yes"
while [[ $input = "yes" ]]
do
echo "------------"
echo "Unix Calculator"
echo "------------"
# User are given options on what they want to do and the these
# are the different scripts for the math
PS3="Press a for Addition, s for subtraction, m for multiplication and d for division: "
select math in Addition Subtraction Multiplication Division
do
case "$math" in
Addition)
echo "Enter first no:"
read num1
echo "Enter second no:"
read num2
result=`expr $num1 + $num2`
echo Answer: $result
break
;;
Subtraction)
echo "Enter first no:"
read num1
echo "Enter second no:"
read num2
result=`expr $num1 - $num2`
echo Answer: $result
break
;;
Multiplication)
echo "Enter first no:"
read num1
echo "Enter second no:"
read num2
result=`expr $num1 * $num2`
echo Answer: $result
break
;;
Division)
echo "Enter first no:"
read num1
echo "Enter second no:"
read num2
result=$(expr "scale=2; $num1/$num2" | bc)
echo Answer = $result
break
;;
#This portion of script is used when the available options
#are not selected...