echo "Enter three sides of a triangle "
read a b c
if test $a -gt $b
then
if test $a -gt $c
then
if test `expr $b + $c` -gt $a
then
e=`expr $a + $b + $c`
s=`expr $e / 2`
x=`expr $s - $a`
y=`expr $s - $b`
z=`expr $s - $c`
eq=`expr $s \* $x \* $y \* $z`
area=$(echo "sqrt ($eq)" | bc -l )
echo "$area is the area of this triangle "
else
echo "This is not the sides of a valid triangle. Please, Enter a valid sides"
fi
else
if test `expr $a + $b` -gt $c
then
e=`expr $a + $b + $c`
s=`expr $e / 2`
x=`expr $s - $a`
y=`expr $s - $b`
z=`expr $s - $c`
eq=`expr $s \* $x \* $y \* $z`
area=$(echo "sqrt ($eq)" | bc -l )
echo "$area is the area of this triangle "
else
echo "This is not the sides of a valid triangle. Please, Enter a valid sides"
fi
fi
else
if test $b -gt $c
then
if test `expr $a + $c` -gt $b
then
e=`expr $a + $b + $c`
s=`expr $e / 2`
x=`expr $s - $a`
y=`expr $s - $b`
z=`expr $s - $c`
eq=`expr $s \* $x \* $y \* $z`
area=$(echo "sqrt ($eq)" | bc -l )
echo "$area is the area of this triangle "
else
echo "This is not the sides of a valid triangle. Please, Enter a valid sides"
fi
else
if test `expr $b + $a` -gt $c
then
e=`expr $a + $b + $c`
s=`expr $e / 2`
x=`expr $s - $a`
y=`expr $s - $b`
z=`expr $s - $c`
eq=`expr $s \* $x \* $y \* $z`
area=$(echo "sqrt ($eq)" | bc -l )
echo "$area is the area of this triangle "
else
echo "This is not the sides of a valid triangle. Please, Enter a valid sides"
fi
fi
fi
No comments:
Post a Comment