#!/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."
# 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 底端
shell脚本结合函数实现简单计算器功能
原创
©著作权归作者所有:来自51CTO博客作者51tide的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:判断用户输入的是否为目录
下一篇:网络笔记
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Java实现一个简单的计算器
Java编写一个简单的计算器。
System 运算符 字符串 -
模拟实现一个简单的计算器
计算器的实现
操作数 函数指针