test_julia_scripts/Volume.jl

24 lines
475 B
Julia
Raw Normal View History

2020-05-07 17:05:12 +00:00
module Volume
export sphere_volume, cylinder_volume
"Volume of sphere with radius `r`"
sphere_volume(r) = (4/3)*π*r^3
"Volume of cylinder with radius `r` and height `h`"
cylinder_volume(r,h) = circle_area(r)*h
"Surface area of a cylinder of height `h` and radius `r`"
cylinder_area(r) = 2*circle_area(r) + 2*π*r*h
"Area of a triangle"
trianle_area(b,h) = b*h/2
"Area of circle with radius `r`"
circle_area(r) = π*r^2
"Rectangle area"
rectangle_area(h,w) = h*w
end