Calculating geometrical properties of a cylinder: For a right cylinder with circ
ID: 3858691 • Letter: C
Question
Explanation / Answer
#!/bin/bash
echo " Enter radius and height of a cylinder "
read r
read h
if [ $r -le 0 -o $h -le 0 ]
then
echo "The number cannot be negative or zero"
else
echo -n "Enter V to find Volume or S to find Surface area "
read n
if [ "$n" == "V" ]
then
volume=$(echo "scale=3; 3.14 * $r * $r * $h"|bc)
echo "Volume of cylinder is $volume"
elif [ "$n" == "S" ]
then
surface=$(echo "scale=3;2 * 3.14 * ($r * $r) + 2 * 3.14 *$r * $h"|bc)
echo "Surface Area of cylinder is $surface "
else
echo " Invalid entry! "
fi
fi
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.