码迷,mamicode.com
首页 > 其他好文 > 详细

编写一个菜单选择使用加法和乘法运算

时间:2015-02-01 17:25:43      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:

#!/bin/bash
#auther:acf


#!/bin/bash
a=$1
b=$2
sum(){
# echo $(($1 + $2))
read -p "first num " num1
read -p "second num " num2
let c=$num1+$num2

}

cf(){
read -p "first num " num1
read -p "second num " num2

let d=$num1*$num2
# let c=$1*$2
# echo $c
#echo cf result $(($1*$2))

}
menu(){
clear
echo -e "1\tsum"
echo -e "2\tcf"
echo -e "3\texit"
echo -e "please key in your choose"
read option

}

main(){

while true
do
menu
case $option in
1)

sum
echo "your first num + second num is $c"
echo "if you want return menu,please input 0 or input another num to out!"
read f
if [ $f == 0 ];then
clear
continue
else break
fi;;


2)
cf
echo "your first num * second num is $d"
echo "if you want return menu,please input 0 or input another num to out!"
read f
if [ $f == 0 ];then
clear
continue
else break
fi;;
3)
break;;

*)

clear
echo "sorry,wrong selection"
;;

esac

done

}
main

编写一个菜单选择使用加法和乘法运算

标签:

原文地址:http://www.cnblogs.com/blog-acf/p/4265684.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!