-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalculator.sh
More file actions
64 lines (54 loc) · 1.42 KB
/
Calculator.sh
File metadata and controls
64 lines (54 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
function welcome {
echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
echo " WELCOME TO SHELL CALCULATOR $name "
echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
echo " Choose the one of the operations from below:"
echo " a: Addition "
echo " b: Subtraction "
echo " c: Multiplication "
echo " d: Division "
}
function addition {
echo " You choose Addition"
echo " Enter the two numbers: "
read num1
read num2
let sum=$num1+$num2
echo " Addition of $num1 and $num2 is $sum"
}
function subtraction {
echo " You choose Subtraction"
echo " Enter the two numbers: "
read num1
read num2
let sub=$num1-$num2
echo " Subtraction of $num1 and $num2 is $sub"
}
function multiplication {
echo " You choose Multiplication"
echo " Enter the two numbers: "
read num1
read num2
let mul=$num1*$num2
echo " Multiplication of $num1 and $num2 is $mul"
}
function division {
echo " You choose Division"
echo " Enter the two numbers: "
read num1
read num2
let div=$num1/$num2
echo " Division of $num1 and $num2 is $div"
}
echo " Enter your name: "
read name
welcome
read choice
case $choice in
a) addition;;
b) subtraction;;
c) multiplication;;
d) division;;
*) echo " Invalid Option, Please choose the correct option"
esac