Skip to content

Instantly share code, notes, and snippets.

@mehagel
Created May 6, 2013 21:19
Show Gist options
  • Save mehagel/5528291 to your computer and use it in GitHub Desktop.
Save mehagel/5528291 to your computer and use it in GitHub Desktop.
def get_grade(array)
sum=array.inject(0){|sum,i| sum + i}
avg = sum/array.length
if avg >=90
puts "A"
return
elsif avg >= 80
puts "B"
return
elsif avg >= 70
puts "C"
return
elsif avg >= 60
puts "D"
return
else
puts "F"
return
end
end
get_grade([99,95,96,89])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment