Write a Select Case statement that tests the value of the integer variable semester Average and assigns a grade to the string variable grade based upon the usual criteria (i.e., greater than or equal to 90 is an A, between 80 and 89 inclusively is a B, etc).  If the average falls outside the range of 0 and 100, grade should be assigned the empty string and the message “Invalid semester average” should be displayed in a message box.

LANGUAGE: Visual Basic

CHALLENGE: Write a Select Case statement that tests the value of the integer variable semester Average and assigns a grade to the string variable grade based upon the usual criteria (i.e., greater than or equal to 90 is an A, between 80 and 89 inclusively is a B, etc).  If the average falls outside the range of 0 and 100, grade should be assigned the empty string and the message “Invalid semester average” should be displayed in a message box.

SOLUTION:


Select Case semesterAverage
    Case 90 to 100
        grade = ("A")
    Case 80 to 89
        grade = ("B")
    Case 70 to 79
        grade = ("C")
    Case 60 to 69
        grade = ("D")
    Case 0 to 59
        grade = ("F")
    Case Else
        MessageBox.Show("Invalid semester average")
        grade = ("")
End Select