Question: 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

 Q2) THE CIRCLE CLASS Write a utility class Circle and a

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!