Search Here

Shell Script to read coordinates of vertices of a triangle and check whether they form a triangle or not


echo -e "\nEnter first coordinate :\c"
read a1 b1
echo -e "\n\t\tFirst coordinate is ($a1,$b1)"
echo -e "\nEnter second coordinate :\c"
read a2 b2
echo -e "\n\t\tSecond coordinate is ($a2,$b2)"
echo -e "\nEnter third coordinate :\c"
read a3 b3
echo -e "\n\t\tThird coordinate is ($a3,$b3)"
(( c= (a1*b2+a2*b3+a3*b1)-(a2*b1+a3*b2+a1*b3) ))
if [ $c -eq 0 ]
then
    echo -e "\nNOT TRIANGLE"
else
    echo -e "\TRIANGLE"
fi

No comments:

Post a Comment