Ad

Convert a grade out of 100 to a letter grade.

Here are the criteria: used in assessing:

90-100 points = A

80-89 points = B

70-79 points = C

60-69 points = D

0-59 points = F

Make sure to return "Not a grade" for integers that are not equal to or between 100.

Code
Diff
  • func gradeCalc(_ score: Int) -> String {
      switch score {
      case 90...100: return "A"
      case 80..<90: return "B"
      case 70..<80: return "C"
      case 60..<70: return "D"
      case 0..<60: return "F"
      default: return "Not a grade"
      }
    }
    • func gradeCalc(_ score: Int) {
    • // Your Code under here
    • func gradeCalc(_ score: Int) -> String {
    • switch score {
    • case 90...100: return "A"
    • case 80..<90: return "B"
    • case 70..<80: return "C"
    • case 60..<70: return "D"
    • case 0..<60: return "F"
    • default: return "Not a grade"
    • }
    • }