Files

29 lines
414 B
Plaintext
Raw Permalink Normal View History

2024-11-02 15:11:00 +00:00
package net.doorstuck.test
cout put:'Finds the sum of a set of numbers.'.
2024-11-02 15:11:00 +00:00
sum = 0.
2024-11-02 15:11:00 +00:00
while true do
cout print:'Number (blank to finish): '.
cout flush.
2024-11-02 15:11:00 +00:00
v = 0.
2025-11-07 10:07:44 +00:00
input = cin read-line.
2024-11-02 15:11:00 +00:00
if input == '' then
break
end
v = Int parse:input.
if v == null then
cout put:'{input} is not a valid number.'.
2024-11-02 15:11:00 +00:00
continue
end
sum += v.
2024-11-02 15:11:00 +00:00
end
cout put:'Sum: {sum}'