Created
          February 8, 2013 05:52 
        
      - 
      
 - 
        
Save nibanez80/4736944 to your computer and use it in GitHub Desktop.  
    Exercise: Calculate the letter grade of a series of grades
Create a method get_grade that accepts an Array of test scores. Each score in the array should be between 0 and 100, where 100 is the max score. Compute the average score and return the letter grade as a String, i.e., 'A', 'B', 'C', 'D', 'E', or 'F'.
  
        
  
    
      This file contains hidden or 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 get_grade(array) | |
| average = (array.inject(:+) / array.size) | |
| if average >= 90; "A" | |
| elsif average >= 80; "B" | |
| elsif average >= 70; "C" | |
| elsif average >= 60; "D" | |
| else average >= 50; "F" | |
| end | |
| end | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment