-
Notifications
You must be signed in to change notification settings - Fork 94
Expand file tree
/
Copy pathcal-func.sh
More file actions
37 lines (37 loc) · 894 Bytes
/
cal-func.sh
File metadata and controls
37 lines (37 loc) · 894 Bytes
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
#!/bin/bash
clear
echo "--------------------------------"
echo "-------welcome to calculator----"
echo "--------------------------------"
read_input()
{
read -p "Enter first number: " num1
read -p "Enter second number: " num2
}
echo -e "[a]ddition\n[b]Subtraction\n[c]Multiplication\n[d]Division\n"
read -p "Enter your choice: " choice
case $choice in
[aA])
read_input
result=$((num1+num2))
echo "The result for your choice is: $result"
;;
[bB])
read_input
result=$((num1-num2))
echo "The result for your choice is: $result"
;;
[cC])
read_input
result=$((num1*num2))
echo "The result for your choice is: $result"
;;
[dD])
read_input
result=$((num1/num2))
echo "The result for your choice is: $result"
;;
*)
echo "Wrong choice"
;;
esac