Skip to content

Instantly share code, notes, and snippets.

@casey-chow
Created April 19, 2011 00:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save casey-chow/926571 to your computer and use it in GitHub Desktop.
Save casey-chow/926571 to your computer and use it in GitHub Desktop.
print "Enter numbers, separated by commas: "
numbers = gets.chomp.split(/,/)
#total = 0
numbers.each do |number|
number = number.to_f
total = total + number
end
average = total / numbers.length
puts "Average of numbers: #{average.round(2)}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment