You are on page 1of 5

ASSIGNMENT NO :9

Name : Lohar Vijay Ravindra


Class : BCA-III
Roll No : 22
Sub : Lab on Linux Programming

Que. Write a menu driven shell program in LINUX to perform tasks,


1) Area of Circle
2) Area of Rectangle
3) Area of Square
4) Area o Triangle
5) Exit

echo "1.Area of Circle"


echo "2.Area of Rectangle"
echo "3.Area of Square"
echo "4.Area of Traingle"
echo "5.Exit"

echo "\nEnter the choice of operation:-"


read c
case $c in

1)
echo -n "Enter radius of circle: "
read r
echo -n "\nArea of circle is : $carea"
carea= echo "3.14 * $r * $r" | bc
;;

2)
echo -n "Enter Length of Rectangle: "
read l
echo -n "Enter Breath of Rectangle: "
read b
rarea=`expr $l \* $b`
echo "\nArea of Rectagle is: $rarea"
;;

3)
echo -n "Enter Length of Square: "
read l
sarea=`expr $l \* $l`
echo "\nArea of Square is: $sarea"
;;

4)
echo -n "Enter base of a triangle : "
read b
echo -n "Enter height of a triangle : "
read h
area=$(echo "scale=2;(1/2) * $b * $h"|bc)
echo "\nArea of a triangle is: $area"
;;

*)exit
;;

esac
OUTPUT SCREENS

You might also like