Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write code to create a \"Circle\" class. The Circle class should meet the follow

ID: 3623257 • Letter: W

Question

Write code to create a "Circle" class.

The Circle class should meet the following specs:

* Circles should have the following 3 instance variables ("properties"):
An x coordinate and a y coordinate, which store the coordinates
of the circle's center.
A property named R, which stores the radius of the circle.
Note: for the 3 properties, choose reasonable data types.

* Your Circle class should have a default constructor,
and a 3-parameter customized constructor.
Note: your default constructor can create a "unit circle", if you want.

* Circles should have a "whatsMyArea()" instance method ("behavior"):
When a program gives this command to a particular circle object,
that circle should compute and "return" its area to the calling routine.

* Your Circle class should have a "calcAreaForThisRadius" "class method":
It receives one parameter value, which represents some specified radius.
The calcAreaForThisRadius class method should then compute and "return"
(to the calling routine) the correct area (based on that radius).

Explanation / Answer

please rate - thanks

import java.util.*;
public class circletest
{
public static void main(String[] args)
{circle a=new circle();
circle b=new circle(0,0,5);
System.out.println("Area a="+whatsMyArea(a));
System.out.println("Area b="+whatsMyArea(b));
}
public static double whatsMyArea(circle a)
{return a.calcAreaForThisRadius();
}
}

-----------------------------------------------

public class circle
{double x,y,R;
public circle(double w,double y,double z)
{x=w;
y=y;
R=z;
}
public circle()
{x=1;
y=1;
R=1;
}
public double calcAreaForThisRadius()
{return Math.PI*R*R;
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote