CS 1401 Introduction to Computer Science
Fall 2012, Lab 11

Background. By definition, Grade Point Average (GPA) is the average of several grades, i.e., the sum of all the grades divided by the total number of classes. It makes sense only if a student has taken at least one class, otherwise, the formula for GPA turns into a meaningless expression 0/0.

In Part 1 of Lab 9, when designing a method gpa, we assumed that a student has taken at least one class, so the Grade Point Average always makes sense. When you apply the corresponding gpa method to the situation when none of the classes is taken, you will get a formal-sounding error message.

Assignment. Your task in this lab is to use exceptions (as described in Chapter 14 and as described in class) to modify your gpa method in the following way:

For extra credit. The program designed according to Part 2 of Lab 9 asks the user to fill in the student grades as integers. This program assumes that the user always types in an integer. Use exceptions to make sure that: