Skip to content

Instantly share code, notes, and snippets.

@dmehrotra
Created August 22, 2013 14:48
Show Gist options
  • Save dmehrotra/6308209 to your computer and use it in GitHub Desktop.
Save dmehrotra/6308209 to your computer and use it in GitHub Desktop.
AverageCalculate
score_array = [75, 100, 85, 65, 84, 87, 95]
puts "the lowest score is: #{score_array.sort![0]}"
puts "the Highest score is: #{score_array.last}"
def average(scores,length)
sum = 0
scores.each do |x|
sum += x
end
average = sum / length
return average
end
puts "the Average score is: #{average(score_array, score_array.length)}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment