Skip to content

Instantly share code, notes, and snippets.

@kmandreza
Created December 28, 2012 19:13
Show Gist options
  • Save kmandreza/4400991 to your computer and use it in GitHub Desktop.
Save kmandreza/4400991 to your computer and use it in GitHub Desktop.
Create a method get_grade that accepts an average in the class and returns the letter grade as a String. It should only return one of 'A', 'B', 'C', etc. Don't worry about + and - grades. For example, get_grade(89) # => returns "B", *not* "B+" get_grade(70) # => returns "C"
def get_grade(num)
if num >= 90
return "A"
end
if num >= 80 && num <= 89
return "B"
end
if num >= 70 && num <= 79
return "C"
end
if num >= 60 && num <= 69
return "D"
end
if num <= 59
return "F"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment