Created
August 22, 2013 14:48
-
-
Save dmehrotra/6308209 to your computer and use it in GitHub Desktop.
AverageCalculate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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