-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdvMaxMin.sh
executable file
·44 lines (39 loc) · 1.12 KB
/
AdvMaxMin.sh
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
#!/bin/bash
#To find Min Expression
function findMinExp(){
if (( $expOne <= $expTwo )) && (( $expOne <= $expThree )) && (( $expOne <= $expFour ))
then
echo "Min:" $expOne
elif (( $expTwo <= $expOne )) && (( $expTwo <= $expThree )) && (( $expTwo <= $expFour ))
then
echo "Min:" $expTwo
elif (( $expThree <= $expOne )) && (( $expThree <= $expTwo )) && (( $expThree <= $expFour ))
then
echo "Min:" $expThree
else
echo "Min:" $expFour
fi
}
#To find Max Expression
function findMaxExp(){
if (( $expOne >= $expTwo )) && (( $expOne >= $expThree )) && (( $expOne >= $expFour ))
then
echo "Max:" $expOne
elif (( $expTwo >= $expOne )) && (( $expTwo >= $expThree )) && (( $expTwo >= $expFour ))
then
echo "Max:" $expTwo
elif (( $expThree >= $expOne )) && (( $expThree >= $expTwo )) && (( $expThree >= $expFour ))
then
echo "Max:" $expThree
else
echo "Max:" $expFour
fi
}
read -p "Enter a,b, and c in numbers:" a b c
expOne=$(( a+b*c ))
expTwo=$(( a%b+c ))
expThree=$(( c+a/b ))
expFour=$(( a*b+c ))
echo $expOne $expTwo $expThree $expFour
findMinExp expOne expTwo expThree expFour
findMaxExp expOne expTwo expThree expFour