14 lines
353 B
Text
14 lines
353 B
Text
local n = 0
|
|
local sum = 0
|
|
while true do
|
|
io.write("Enter integral rainfall (99999 to quit): ")
|
|
local i = tonumber(io.read())
|
|
if !(i and i % 1 == 0) then
|
|
print("Must be an integer, try again.")
|
|
continue
|
|
end
|
|
if i == 99999 then break end
|
|
++n
|
|
sum += i
|
|
print($" The current average rainfall is {sum / n}")
|
|
end
|