-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharea_volume.sh
96 lines (75 loc) · 1.99 KB
/
area_volume.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash
# Mini script for computing geometric volumes and areas
# Launch the script for possible actions
function cylinder() {
echo "Pass the height of the cylinder: ";
read h;
echo "Pass the radius of the cylinder base: ";
read r;
v=$(( 3,14*"$r"*"$r"*"$h" ));
pp=$(( 3,14*"$r"*"$r"));
ppb=$(( 3,14*2*"$r"*"$h"));
p=$(($pp+$pp+$ppb));
echo -e "\n CYLINDER DATA:";
echo "Volume: "$v"";
echo "Base Area: "$pp"";
echo "Side Area: "$ppb"";
echo "Total Area: "$p"";
}
function sphere() {
echo "Pass the radius of the sphere: ";
read r;
v=$(( "$r"*"$r"*"$r"*(4/3)*3,14 ));
p=$(( 4*3,14*"$r"*"$r"));
echo -e "\n SPHERE DATA:";
echo "Volume: "$v"";
echo "Total Area: "$p"";
}
function cone() {
echo "Pass the height of the cone: ";
read h;
echo "Pass the radius of the cones base: ";
read r;
l=$(echo "scale=0; sqrt($h^2 + $r^2)" | bc)
v=$(( (3,14/3)*"$r"*"$r"*"$h" ));
pp=$(( 3,14*"$r"*"$r"));
ppb=$(( 3,14*"$r"*"$l"));
p=$(($pp+$ppb));
echo -e "\n CONE DATA:";
echo "Volume: "$v"";
echo "Base Area: "$pp"";
echo "Side Area: "$ppb"";
echo "Total Area: "$p"";
}
function cube() {
echo "Pass the edge of the cube: ";
read a;
v=$(("$a"*"$a"*"$a" ));
pp=$(( "$a"*"$a"));
p=$(($pp*6));
echo -e "\n CUBE DATA:";
echo "Volume: "$v"";
echo "Base Area: "$pp"";
echo "Total Area: "$p"";
}
function mainMenu(){
echo -e "\n WELCOME IN ARE_VOLUME PROGRAM, CHOOSE YOUR FIGURE: \n "
select y in CYL SPH CONE CUBE Quit
do
case $y in
"CYL") echo -e "YOU CHOSE: CYLINDER \n"
cylinder ;;
"SPH") echo -e "YOU CHOSE: SPHERE \n"
sphere ;;
"CONE") echo -e "YOU CHOSE: CONE \n"
cone ;;
"CUBE") echo -e "YOU CHOSE: CUBE \n"
cube ;;
"Quit") exit ;;
*) echo "YOU DIDN'T MAKE APPROPRIATE DECISION! Exiting ... "
exit 1
esac
break
done
}
mainMenu