Created
August 18, 2014 01:09
-
-
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.
This file contains 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
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 |
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
Min
Same comments as with
#max