Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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();

}

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Seven Databases In Seven Weeks A Guide To Modern Databases And The NoSQL Movement

Authors: Luc Perkins, Eric Redmond, Jim Wilson

2nd Edition

1680502530, 978-1680502534

More Books

Students also viewed these Databases questions