First commit
This commit is contained in:
25
exercises/ch03/ex3_6.lua
Normal file
25
exercises/ch03/ex3_6.lua
Normal file
@@ -0,0 +1,25 @@
|
||||
function Calculate_volume(height, angle)
|
||||
local r = math.tan(angle) * height
|
||||
return 1/3 * math.pi * r^2 * height
|
||||
end
|
||||
|
||||
function Tests()
|
||||
-- height, angle
|
||||
local cases = {
|
||||
{ 4.03, 3.55 },
|
||||
{ 308, 380 },
|
||||
{ 0.394, 0.826 }
|
||||
}
|
||||
|
||||
for i = 1, #cases do
|
||||
local case = cases[i]
|
||||
local height = case[1]
|
||||
local angle = case[2]
|
||||
|
||||
local volume = Calculate_volume(height, angle)
|
||||
|
||||
print(string.format("height: %f, angle: %f, volume: %f", height, angle, volume))
|
||||
end
|
||||
end
|
||||
|
||||
Tests()
|
||||
Reference in New Issue
Block a user