您好,登錄后才能下訂單哦!
#!/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
模板
#!/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
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。