Question: Java based programming. The NotGradeException Class Create a new exception class called NotGradeException that extends Exception class. The new exception class contains only four constructors
Java based programming.
The NotGradeException Class
Create a new exception class called NotGradeException that extends Exception class. The new exception class contains only four constructors as described in slide #4 in the second PowerPoint file for chapter 11. You should use the following message as the default error message for the first constructor:
Input Value Is Not a Grade
The AverageGrade Class
Create an application class called AverageGrade with the following task for its main method:
static void main(String[] args)
Asks for three numbers between 0 and 100 as input grades to calculate and show the average grade.
Use exception handling to process any InputMistMachExceptions and NotGradeException that arise.
Note: In the try block use an if statement that throws a new NotGradeException if the input grade is not in the range of 0 to 100.
The following code shows an example of throwing a new exception in an if statement:
if(condition)
{
throw new Exception();
}

Enter three numbers between 0 and 100 as input grades Please enter grade l: 86 Please enter grade 2: Exception: java.util. InputMi.smatchException You must enter numbers. Please try acgain Enter three numbers between 0 and 100 as input grades Please enter grade 1: 86 Please enter grade 2 174 Exception: NotGradeException: Input Value Is Not a Grade You must enter a number between and 100. Please try again Enter three numbers between O and 100 as input grades Please enter grade l: 86 Please enter grade 2: 74 Please enter grade 3: 97 Average grade is: 85.67
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
