We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1dbd99a commit 9cb5624Copy full SHA for 9cb5624
calculator.sh
@@ -0,0 +1,36 @@
1
+#!/bin/bash
2
+
3
+#This is a simple script to calculate two numbers.
4
5
+# Taking user input
6
7
+echo "Enter two numbers: "
8
+read a
9
+read b
10
11
+#input type of operation
12
13
+echo "Enter your choice: "
14
+echo "1. Addition"
15
+echo "2. Substraction"
16
+echo "3. Multiplication"
17
+echo "4. Division"
18
+read ch
19
20
+#Acting on the user input
21
22
+case $ch in
23
+ 1) res=`echo $a + $b | bc`
24
+ ;;
25
+ 2) res=`echo $a - $b | bc`
26
27
+ 3) res=`echo $a \* $b | bc`
28
29
+ 4) res=`echo "scale=2; $a / $b" | bc`
30
31
+esac
32
33
+#Printing result
34
+echo "Result: $res"
35
36
0 commit comments