Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q2) THE CIRCLE CLASS Write a utility class Circle and a driver class CircleTest test each constructor and method in the class. Recall that the

image text in transcribed

Q2) THE CIRCLE CLASS Write a utility class Circle and a driver class CircleTest test each constructor and method in the class. Recall that the Math class defines the constant public static final double PI A Circle object should have one instance variable double radius and one class constant that defines the default radius of 1 Include two constructors: o public Circle(double r) initializes the radius to r o public Circle() initializes the radius to the default radius Include the following methods: o public double area() returns the area (ar2 )of this Circle o public double circumference) returns the circumference (2r) of this Circle o public double diameter() o public String toString() returns a String representation of this Circle such as "Circle with radius 2.5" public void setRadius(double r) sets the radius to r public double getRadius() returns the radius of this Circle o o Q3) THEAREA CLASS Write a program Area.java that uses both Rectangle and Circle objects to find the area of the shaded region. All of the cutout comers are squares with side 2. The area should be printed, rounded to one decimal place. 35.5 7.5

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

More Books

Students also viewed these Databases questions

Question

1. Who should participate and how will participants be recruited?

Answered: 1 week ago