|
发表于 2005-11-12 22:50:08
|
显示全部楼层
#!/bin/bash
echo "Caculator:"
while true
do
echo -n "a)+ b)- c)* d)/ x)=exit "
echo -n "input:"
read op
case $op in
a) op="+" ;;
b) op="-" ;;
c) op="*" ;;
d) op="/" ;;
x) exit ;;
*) echo "wrong ,input again..."
continue ;;
esac
echo "input two numbers:"
read n1 n2
echo -n "$n1""$op""$n2"
if test $op="/" && test $n2 -eq 0
then
echo divide by 0
else
RESULT=$[$n1$op$n2]
echo "="$RESULT
fi
echo -n "continue (y/n)? "
read answer
case $answer in
n) break;;
y) continue;;
*) echo "wrong input!! error!!!"
break;;
esac
done
echo "bye" |
|