The function
gradeToNum simply converts a single char to a numerical value. @VX0726 was suggesting this earlier.
case is really just a part of the
switch block - see the last items in
http://www.cplusplus.com/doc/tutorial/control/
It's a very routine part of C or C++ (or, in some form or other, most programming languages) - it's simply neater than a whole sequence of
if ... else if statements. You would usually include
break statements, but they aren't needed here because you return directly from the function at each case.
tolower is simply taking care when the user has accidentally left the caps-lock key on and forcing the grade to be tested in lower case.
Alternatives?
I suppose you could
return 4 - ( c - 'a' );
for letter grades c = 'a', 'b', 'c' or 'd', but it's hardly obvious coding. Using some associative container like a map would be over-complicating it too.
In the
main() routine, whenever you find yourself doing almost exactly the same thing repeatedly, consider using arrays and/or loops. Here, it would also make it much easier to change the number or name of courses as well.