Purpose - East Tennessee State University



PurposeThe purpose of this exercise is to gain experience with exception handling including the use of the try-catch mechanism. The context of the exercise is the calculation of a grade point average based on the number of credits earned and the number of credit hours completed. All .java files should be in the gpaCalculator package. SpecificationsA GPACalculator class that computes a GPA based on a number of credits earned and the number of credit hours completed is provided. It checks for several types of input errors and throws exceptions with appropriate error messages in them. A GPAException class is also provided. Spend some time studying and understanding the GPACalculator class and review the methods provided by the GPAException class before you start writing the driver.Make no changes to either of these provided classes. Use them as they are.You should create a driver class that handles all input and output including the error messages. Where exceptional conditions are detected by the GPACalculator class and exceptions are thrown, display the error messages those exception objects contain rather than hard-coding your own messages.Use the exception handling mechanism to deal with all problematic situations including, but not limited to the following:Dividing by 0Negative values for either hours or credits or bothA combination of hours and credits that results in an invalid GPA (i.e., a GPA not between 0.00 and 4.00)Invalid input (hours or credits not an integer)The GPACalculator class provided detects all exceptional conditions other than invalid numeric input and throws appropriate exceptions.The driver class should do all I/O including error messages. The driver class must catch all exceptions in this exercise. The GPA should always have exactly two digits after the decimal and one digit before the decimal.At least two different exception types might be thrown in this exercise. The GPAException class is provided and it represents one type of exception thrown by GPACalculator. At the end of this document, there is a sample of output produced by a solution to this exercise. Your output should be similar if the same input is provided.SubmissionSubmit a zipped file containing your .Java files only for this exercise (include GPACalculator.java and GPAException.java with your driver file). Name the submission CW6 – ExceptionHandling plus your course, section, and name as specified in the Course Facts on the course web site. This must be submitted by the end of class today. Example Output from One Solution ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download