Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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)

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)
image text in transcribed
image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

5. If yes, then why?

Answered: 1 week ago

Question

6. How would you design your ideal position?

Answered: 1 week ago