-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCal.sh
More file actions
executable file
·104 lines (95 loc) · 1.81 KB
/
Cal.sh
File metadata and controls
executable file
·104 lines (95 loc) · 1.81 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/bash
#!/bin/sh
#First shell script
echo "Enter Your Name"
read Name
echo "Hello, $Name! Welcome to RN Calculator.Let's start a journey.Hopefully you will enjoying this. Let's start.Are You ready? 1=yes/2=no"
read a
if [ $a -eq 1 ]
then
echo "you are in."
else
echo "Sorry!"
fi
while [ "$a" -eq 1 ];
do
echo "Select One:
1 = checking Even or Odd Number
2 = Add two Number
3 = substraction
4 = multiplication
5 = division
6 = Squre
7 = Squrer-root
0 = Exit "
#checking Even or Odd Number
read b
if test $b -eq 1
then
echo "Enter the Number:"
read c
d=$(expr "$c" % "2")
if test $d -eq 0
then
echo "The Number $c is Even."
else
echo "The Number $c is Odd."
fi
#addition
elif test $b -eq 2
then
echo "Enter 1st Number:"
read x
echo "Enter 2nd Number:"
read y
A=`echo "scale=4; $x + $y" | bc`
echo "Ans: $A "
#substraction
elif test $b -eq 3
then
echo "Enter 1st Number:"
read m
echo "Enter 2nd Number:"
read n
sub=`echo "scale=4; $m - $n" | bc`
echo "Ans: $sub "
#multiplication
elif test $b -eq 4
then
echo "Enter 1st Number:"
read X
echo "Enter 2nd Number:"
read Y
M=`echo "scale=4; $X * $Y" | bc`
echo "Ans: $M "
# Division
elif test $b -eq 5
then
echo "Enter 1st Number:"
read e
echo "Enter 2nd Number:"
read f
div=`echo "scale=4; $e / $f" | bc`
echo "Ans: $div "
#Square
elif test $b -eq 6
then
echo "Enter the Number:"
read sq
squre=`echo "scale=4; $sq * $sq" | bc`
echo "Ans: $squre "
#Squrer-root
elif test $b -eq 7
then
echo "Enter the Number:"
read number
square_root=`echo "scale=4; sqrt($number)" | bc`
echo "Square Root is $square_root"
elif test $b -eq 0
then
echo "Exit! Thank You $Name for using me.See you soon."
break
else
echo "Invalid Keyword ! Try Again."
fi
done