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

Can Someone help me with this? I need this example done so I can understand it b

ID: 3555076 • Letter: C

Question

Can Someone help me with this? I need this example done so I can understand it better. Thanks. 5 star rating for helpful and corrct answer.

1) Copy the abstract class GeometricObject below, and save it in the file GeometricObject.java:

public abstract class GeometricObject
{
public abstract double getArea();
public abstract double getPerimeter();
public String toString()
{
return "GeometricObject: Area=?, Perimeter=?";
}
}
2) Write a subclass of GeometricObject called Circle. Save it in the file Circle.java. Include a member variable
for the circle's radius. Include a constructor that takes the radius of the circle as a parameter. Override the
getArea(), getPerimeter() and toString() methods. The toString() method should print out the circle's radius, and
the area and perimeter of the circle. .
Hint: the class should start with

Explanation / Answer

GeometricObject.java

public abstract class GeometricObject
{
public abstract double getArea();
public abstract double getPerimeter();
public String toString()
{
return "GeometricObject: Area=?, Perimeter=?";
}
}

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

Circle.java.

public class Circle extends GeometricObject

{

double r;

double area;

double perimeter;

Circle(double in){

r=in;

}

public double getArea()

{

area=pi*r2;

}

public double getPerimeter()

{

perimeter=2*pi*r;

}

public string toString()

{System.out.println("Area "+area);

System.out.printf("Perimeter "+perimeter);

}

public static void main(String args[]){

Circle c1=Circle(5.2);

}

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