Answered step by step
Verified Expert Solution
Question
1 Approved Answer
can you please solve 3 questions about the code 3) Consider the following class and answer the questions that follow: public class Circle { public
can you please solve 3 questions about the code
3) Consider the following class and answer the questions that follow:
public class Circle {
public static final double PI = 3.14159;
private double radius;
private double area;
public Circle(double r) {
radius=r;
}
public void calculateArea() { }
public String toString() { }
}
3.1 Complete the body of the method calculateArea() to calculate the area of the
circle.
3.2 Complete the body of the method toString() to return a string representation of the circle in this format:
Radius=the radius rounded to 2 decimal places
Area=the area rounded to 2 decimal places
3.3 Following the toString() method, add an accessor and mutator for the instance variable radius.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started