Shell scripting combines functions for simple calculator functions

Source: Internet
Author: User

#!/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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.