I am trying to create a programme that asks the user for a number, the programme keeps asking the user for a number until "stop" is entered at which point the sum of the numbers is returned.
The code sort of works but I realise that the first puts/gets.chomp is outside of the loop and is not being added to the array. I dont know how to implement this, any help thoughts would be greatly appreciated!
array = []
puts 'Give me a number'
answer = gets.chomp
until answer == "stop"
puts 'Give me a number'
answer = gets.chomp
array.push(answer)
end
array.pop
array
answer = nilbefore loop and all must be finesum = 0and keep incrementing it by the input as long as the input is numeric. There's no need to store all the inputs.