Last active
August 29, 2015 13:56
-
-
Save laurenkruczyk/9203291 to your computer and use it in GitHub Desktop.
Resubmitted to show I now understand the concept.
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
numbers= [75, 100, 85, 65, 84, 87, 95] | |
def average (numbers) | |
sum=0 | |
numbers.each do |num| | |
sum += num | |
end | |
sum/numbers.length.to_f | |
end | |
def lowest (numbers) | |
minimum=numbers[0] | |
numbers.each do |num| | |
if num<minimum | |
minimum=num | |
end | |
end | |
minimum | |
end | |
def highest(numbers) | |
maximum=numbers[0] | |
numbers.each do |num| | |
if num > maximum | |
maximum = num | |
end | |
end | |
maximum | |
end | |
puts average(numbers) | |
puts lowest(numbers) | |
puts highest(numbers) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment