Answered step by step
Verified Expert Solution
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 for radius and length.
An int static data field named numberOfObjects. The default value is 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 noarg constructor;
create a second cylinder using the constructor with arguments to set radius to and
length to ;
create a third cylinder using the noarg constructor;
change the third cylinder's radius to and length to 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: and the length is:
The base area of the second cylinder is:
The volume of the third cylinder is:
The amount of objects created is:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started