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
pub fn square(length: f64) -> f64 {
return length * length;
}
pub fn rectangle(length: f64, width: f64) -> f64 {
return length * width;
}
pub fn triangle(base: f64, height: f64) -> f64 {
return (base * height) / 2.0;
}
pub fn rhombus(large_diagonal: f64, small_diagonal: f64) -> f64 {
return (large_diagonal * small_diagonal) / 2.0;
}
pub fn trapezoid(large_side: f64, small_side: f64, height: f64) -> f64 {
return ((large_side + small_side) / 2.0) * height;
}
pub fn polygon(perimeter: f64, apothem: f64) -> f64 {
return (perimeter / 2.0) * apothem;
}
pub fn circle(radius: f64) -> f64 {
return std::f64::consts::PI * radius * radius;
}
pub fn cone(radius: f64, slant_height: f64) -> f64 {
return std::f64::consts::PI * radius * slant_height;
}
pub fn sphere(radius: f64) -> f64 {
return 4.0 * std::f64::consts::PI * radius * radius;
}