Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Design a class named Cylinder to represent cylinders. The class contains: Two private double data fields named radius and length that specify the radius and

Design a class named Cylinder to represent cylinders. The class contains:
Two private double data fields named radius and length that specify the radius and length
of a cylinder. The default values are 1.0 for radius and length.
An int static data field named numberOfObjects. The default value is 0.A constructor that creates a cylinder with the specified radius and length.A method named getArea() that returns the base area of the cylinder.
A method named getVolume() that returns the volume of the cylinder.Requirements:
Draw the UML diagram for the class. Implement this class. The data fields should be
private, and constructors and all other methods should be public.
Write a test program that should do the following tasks:
> create the first cylinder object using the no-arg constructor;
create a second cylinder using the constructor with arguments to set radius to 2.5 and
length to 12.3 ;
create a third cylinder using the no-arg constructor;
> change the third cylinder's radius to 5.0 and length to 6.5.print out the area of the second cylinder;print out the value of the numOfObjects data field; For this assignment, please name your class file as "Cylinder"
Please name your test program as "CylinderTest"
How to hand in the assignment
Follow the steps below:
Complete the UML in a Microsoft Word document or other document file format, and the
programs in .java files. Once you are done, convert your UML file to a PDF (.pdf).
Upload the .java files as well as the PDF document UML into Gradescope. Do not
submit a .docx file for the UML, first convert your file to PDF (.pdf).
Click "Upload".
I remind you that if you do not submit the assignment before the due date, you will not be able to
submit it.
Note: Your code should look exactly like the output below and should be able to run test cases.
The radius of the first cylinder is: 1.0 and the length is: 1.0
The base area of the second cylinder is: 19.634954084936208
The volume of the third cylinder is: 510.5088062083414
The amount of objects created is: 3
image text in transcribed

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

Recommended Textbook for

Databases Illuminated

Authors: Catherine M Ricardo, Susan D Urban

3rd Edition

1284056945, 9781284056945

More Books

Students also viewed these Databases questions