#!/bin/bash
function Tool_menu ()
{
echo "****************************************************"
echo "* *"
echo "* Calculation Tools *"
echo "* *"
echo "****************************************************"
}
function Menu_choice ()
{
echo "A:add-Num."
echo "B:minus-Num."
echo "c:multiply-Num."
echo "D:divide-Num."
echo "Q:close this function."
echo "Please input your chiose:"
}
function Add_num ()
{
echo "Add."
# echo "Please input your number"
# Read A
# echo "Please input your number"
# Read B
Let c= $a + $b
echo "$a + $b is: $c"
}
function Minus_num ()
{
echo "Minus."
# echo "Please input your number"
# Read A
# echo "Please input your number"
# Read B
Let c= $a-$b
echo "$a-$b is: $c"
}
function Multiply_num ()
{
echo "Multiply."
# echo "Please input your number"
# Read A
# echo "Please input your number"
# Read B
Let c= $a * $b
echo "$a * $b is: $c"
}
function Divide_num ()
{
echo "Divide."
# echo "Please input your number"
# Read A
# echo "Please input your number"
# Read B
Let c= $a/$b
echo "$a/$b is: $c"
}
function Main ()
{
Clear
Tool_menu
While:
Do
Menu_choice
Read Menu_choice
Read a
Read B
Case $menu _choice in
A|a) Add_num $a $b;;
B|B) Minus_num;;
C|C) Multiply_num;;
D|D) Divide_num;;
Q|Q) break;;
*) "error";;
#read A
#read b
#add_num $a $b
Esac
# Minus_num $a $b
# Multiply_num $a $b
# Devide_num $a $b
Done
}
Main
Exit 0
92,1 Bottom
This article is from the "12146768" blog, please be sure to keep this source http://12156768.blog.51cto.com/12146768/1872211
Shell scripting combines functions for simple calculator functions