Skip to content

Instantly share code, notes, and snippets.

@akcrono
Created August 18, 2014 01:09
Show Gist options
  • Save akcrono/8266bf1bf60c80c17e65 to your computer and use it in GitHub Desktop.
Save akcrono/8266bf1bf60c80c17e65 to your computer and use it in GitHub Desktop.
first systems check for Launch Academy. 3 methods returning average, max, and min scores.
def find_average scores
sum = 0.0
scores.each do |x|
sum += x
end
return sum/scores.length
end
def find_max scores
answer = 0
scores.each do |x|
answer = x if x > answer
end
return answer
end
def find_min scores
answer = scores[0]
scores.each do |x|
answer = x if x < answer
end
return answer
end
scores = [75, 100, 85, 65, 84, 87, 95]
puts find_average scores
puts find_max scores
puts find_min scores
@HeroicEric
Copy link

Nice job! Please put in a help request if you have any questions about any of my comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment