I need to update this hash with as many items as the user wants. And I have a problem with updating it. It only shows the last input from user.
For example in i = 2, the hash will only show the second key and value added, and I want both. Or if i = 3 i need all three inputs.
puts "how may items to add in hash?"
i=gets.chomp.to_i
for i in 1..i
puts "add key"
key = gets.chomp
puts "add value"
value = gets.chomp.to_f.round(2)
project = Hash.new()
project = {key => value}
project.each do |key, value|
puts "#{key} \t - \t #{value}%"
end
end
Anyone that can help?