Question: i am confused about how to write the string class for the class circle since circumference and area are never declared as intance variables (inheritence)
Circle.java 3 1 public class Circle f 3 private double radius; 4 5e public Circle() radius 0; 9 0 public Circle(double aRadius) L1 f .2 radius-aRadius; 4 5 public void getCircumference() 7 double circumference; circumference-2*3.14*radius; Lepublic void getArea() double area: area-2*3.14*radius; e public String tostring() return "Circumference: "ircumference+"\t"+"Area: area; Create a class Circle that takes a data field radius. Create a constructor with parameter and implement methods getCircumference, getArea, and toString. The toString method returns a description of the circumference and area of the circle. Create a class Cylinder that extends the Circle class. It has an additional data field, height. Create a constructor with parameters and implement methods getArea, getVolume, and toString. The toString method returns a description of the area and volume of the cylinder Area of circle = r2 Circumference of circle 2r Total surface area of cylinder 2tr+2nrh -2times area of circle +circumference of circle times height Total volume rrh - Area of circle times height Create a tester. Create a Circle object and a Cylinder object. Print the results of the toString method call on either of the objects you have built
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
