网站建设资讯

NEWS

网站建设资讯

shell简单计算器-创新互联

#!/bin/bash

function tool_menu()
{
   echo "****************************************************"
   echo "*                                                 *"
   echo "*             calculation tools                 *"
   echo "*                                                 *"
   echo "****************************************************"
}
function menu_choice()
{
   echo "A: Add two num."
   echo "B: Minus two num."
   echo "C: Multiply two num."
   echo "D:Divide two num."
   echo "Q: Close this function."
   echo "Please input your chiose:"
}
function add_num()
{
   echo "please inut your first num:"
   read first_num
   echo "please inut your second num:"
   read second_num
   let add=$first_num+$second_num
   echo "$first_num+$second_num=$add"
   return 0
}
function minus_num()
{
   echo "please inut your first num:"
   read first_num
   echo "please inut your second num:"
   read second_num
   let minus=$first_num-$second_num
   echo "$first_num-$second_num=$minus"
   return 0
}
function multiply_num()
{
   echo "please inut your first num:"
   read first_num
   echo "please inut your second num:"
   read second_num
   let multiply=$first_num*$second_num
   echo "$first_num*$second_num=$multiply"
   return 0
}

function divide_num()
{
   echo "please inut your first num:"
   read first_num
   echo "please inut your second num:"
   read second_num
   let divide=$first_num/$second_num
   echo "$first_num/$second_num=$divide"
   return 0
}
function main()
{
   clear
   tool_menu
   while :
   do
       menu_choice
       read menu_choice
       case $menu_choice in
           A|a) add_num ;;
           B|b) minus_num ;;
           C|c) multiply_num ;;
           D|d) divide_num ;;
           Q|q) break;;
           *) echo "Input error,please try agin.";;
       esac
   done
}
main
exit 0

成都创新互联主要从事成都做网站、网站设计、外贸营销网站建设、网页设计、企业做网站、公司建网站等业务。立足成都服务福海,十多年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:18980820575

 模板
#!/bin/bash

function tool_menu()
{
   echo "****************************************************"
   echo "*                                                 *"
   echo "*             calculation tools                 *"
   echo "*                                                 *"
   echo "****************************************************"
}
function menu_choice()
{
   echo "A: Add two num."
   echo "B: Minus two num."
   echo "C: Multiply two num."
   echo "D:Divide two num."
   echo "Q: Close this function."
   echo "Please input your chiose:"
}
function add_num()
{

   echo "add."
}
function minus_num()
{

   echo "minus."
}
function multiply_num()
{
   echo "multiply."

}

function divide_num()
{

   echo "divide."

}
function main()
{
   clear 模板

   tool_menu
   while :
   do
       menu_choice
       read menu_choice
       case $menu_choice in
           A|a) add_num ;;
           B|b) minus_num ;;
           C|c) multiply_num ;;
           D|d) divide_num ;;
           Q|q) break;;
           *) echo "Input error,please try agin.";;
       esac
   done
}
main
exit 0

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


文章名称:shell简单计算器-创新互联
文章来源:http://cdweb.net/article/dhhcss.html