Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Java Task 2: Exception Handling In this task, you are going to practice the exception handling. Assume that you need to write one class

image text in transcribedimage text in transcribed

In Java

Task 2: Exception Handling In this task, you are going to practice the exception handling. Assume that you need to write one class (i.e. named CircleWithException) to describe the circle object. In CircleWithException, you have to declare the variables and methods to fulfill the bellowing functionalities. 1. Design the method to set the radius of the circle. 2. Design the method to get the radius of the circle. 3. Design the method to get the area of the circle. 4. Design the method to get the diameter of the circle. In the class, you need to check the validation of the data. If the data is not valid, you shall throw the corresponding exception. For example, if the radius is not a positive number, an IllegalArgumentException should be thrown. If the area is bigger than 1000, a general exception "Exception" should be thrown. In the main function, you need to conduct the exception handling to catch the exceptions to secure your program when you input different radius values. Create a circle for radius 5 Create a circle for radius 1000 Create a circle for radius -5 java.lang. Exception: area cannot be bigger than 1000 this is from finally java.lang.IllegalArgumentException: Radius cannot be negative this is from finally

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

What does stickiest refer to in regard to social media

Answered: 1 week ago