thanks for the fast response I did figure this one out in the mean time I am on the last part atm
Code:
#!/bin/bash
while getopts :rctd: opt; do
case $opt in
r)
echo "Input lengh of a Rectangle: "
read length
echo "Input width of a Rectangle: "
read breadth
echo "Enter the Radius: "
read radius
area=$(echo $length \* $breadth | bc)
perimeter=$(echo 2 \* $length \* $breadth | bc)
echo "Area of the Rectangle:" $area
echo "Permimeter of the Rectangle:" $perimeter
;;
c)
echo -n "Enter The radius of a circle: "
read r
#Forumula that calculates a Circle
area=$(echo "scale=2;3.14 * ($r * $r)" | bc)
#Forumula that calculates a Circle
d=$(echo "scale=2;2 * $r"|bc)
circumference=$(echo "scale=2;3.14 * $d"| bc)
echo "The Area Of The Circle Is $area"
echo "Circumference Of The Circle Is $circumference"
;;
t)
echo "Input the height of Trapezoid: "
read height
echo "Input Base1: "
read Base1
echo "Input Base2: "
read Base2
area=$(echo "($Base1 + $Base2)/2 * $height" | bc)
echo "Area Of The Trapezoid Is:" $area
;;
d)
if [[ $OPTARG = -* ]]; then
((OPTIND--))
continue
fi
echo "(d) argument $OPTARG"
;;
\?)
echo "WTF!"
exit 1
;;
esac
done
Sorry about code post trying to get use to this......
Here is the last part I am working on, if anyone has Ideas
My script should also allow the option, -f. When this option is used in conjunction with -r, -c, or –t, each option takes one argument, the name of the input file. The input values would be read from the input file one line at a time and the areas printed to stdout. The script should terminate when a value of –1 is read. If the -f option is not used the script calculates only one value.