Question: public class Circle { 2 . public double x , y; / / centre of the circle 3 . public double r; / / radius
public class Circle
public double x y; centre of the circle
public double r; radius of circle
Methods to return circumference and area
public double circumference
return r;
public double area
return r r;
User class MyMain
class MyMain
public static void mainString args
Circle aCircle; creating reference
aCircle new Circle; creating object
aCircle.x ; assigning value to data field
aCircle.y ;
aCircle.r ;
double area aCircle.area;
double circumf aCircle.circumference;
System.out.printlnRadiusaCircle.r Areaarea;
System.out.printlnCircumference circumf;
Add another identifier in the class to save the color for the circle and also add a method to
return the color of any object.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
