Files
programming-lua/exercises/ch03/ex3_6.lua
2026-02-19 18:51:17 +02:00

26 lines
544 B
Lua

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()