Problem (Cylinder.java) a. Implement a class called Cylinder. A cylinder has a circle and one additional data member for representing the height (type float). b. Create appropriate constructors for your Cylinder class. c. Encapsulate it. d. Include methods for finding the volume and area of your Cylinder. area = 2 * (area of the circle in this cylinder) + 2 * pi * radius * height volume = (area of the circle in this cylinder) * height e. Override the toString method of the Object class. Try to use the toString of the Circle class and then just concatenate the remaining values. f. Override the equals method of the Object class. Two Cylinder objects are equal if they have the same center and the same radius and the same height. For example:

EBK JAVA PROGRAMMING
8th Edition
ISBN:9781305480537
Author:FARRELL
Publisher:FARRELL
Chapter16: Graphics
Section: Chapter Questions
Problem 8RQ
icon
Related questions
Question

Problem (Cylinder.java)

a. Implement a class called Cylinder. A cylinder has a circle and one additional data member for representing the height (type float).

b. Create appropriate constructors for your Cylinder class.

c. Encapsulate it.

d. Include methods for finding the volume and area of your Cylinder.

area = 2 * (area of the circle in this cylinder) + 2 * pi * radius * height

volume = (area of the circle in this cylinder) * height

e. Override the toString method of the Object class. Try to use the toString of the Circle class and then just concatenate the remaining values.

f. Override the equals method of the Object class. Two Cylinder objects are equal if they have the same center and the same radius and the same height.

 

For example:

Test
Result
Cylinder c = new Cylinder ();
Radius: 4.50
c.setCircle (10,20,4.5f);
Point: (10,20)
c.setHeight (10);
Height: 10.00
System.out.printf ("Radius: .2f\n",c.getCircle ().getRadius () ):
System.out.println ("Point: "+c.getCircle ().getCenter ());
System.out.printf ("Height: $.2f\n",c.getHeight ());
Cylinder c = new Cylinder (new Circle (5,5,10.5f), 25);
Radius: 10.50
System.out.printin (c);
Point: (5,5)
System.out.println ("Area: "+c.getArea () );
Height: 25.00
System.out.println ("Volume: "+c.getVolume () );
Area: 2342.06
Volume: 8659.01
Transcribed Image Text:Test Result Cylinder c = new Cylinder (); Radius: 4.50 c.setCircle (10,20,4.5f); Point: (10,20) c.setHeight (10); Height: 10.00 System.out.printf ("Radius: .2f\n",c.getCircle ().getRadius () ): System.out.println ("Point: "+c.getCircle ().getCenter ()); System.out.printf ("Height: $.2f\n",c.getHeight ()); Cylinder c = new Cylinder (new Circle (5,5,10.5f), 25); Radius: 10.50 System.out.printin (c); Point: (5,5) System.out.println ("Area: "+c.getArea () ); Height: 25.00 System.out.println ("Volume: "+c.getVolume () ); Area: 2342.06 Volume: 8659.01
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage