Question: Please do not use break, continue / exit , return Write a java program for the question below, Save the file with the following format
Please do not use break, continueexit return
Write a java program for the question below, Save the file with the following
format
LastNameFirstNameCitHwBjava
ieFooBarCITHW#java Submit your file to the assignment dropbox in Canvas
Assignment:
The goal of this assignment is to help you understand how to use constructors,
methods, and arrays of objects in Java. You write a Java program to d manipulate
cylinder objects, calculate their surface area and volume, and display their details.
Create a class with the following private data fields:
Radius, height, surfaceArea, and volume.
Create two constructors:
A noargument constructor that sets the radius and height to and call the sets
methods for surface area and volume.
A second constructor, with parameters that accepts a radius and height as input and
initializes the fields accordingly and call the sets methods for surface area and
volume.
Create a get and set methods for the radius, height, surface area and volume
Create set methods for surface area
Calculate the surface area:
Surface Arearrh where r is radius, h is height
Create a set method for Volume
Calculate the volume:
Volumerh
Create a method to get the surface area and volume
Create an Override a toString method that will display Cylinder details
Radius, height, surface area, and volume.
Save the class as the following: your last and first initial with CylinderB for
example if first Name Foo and last Name Bar the class name will be
BFCylinderBjava
Create a class for testing that includes the main method, the class name will be
LastNameFirstNameCitHwBjava
Prompt the user to enter the radius and height of the cylinder.
Create a cylinder object using the parameter constructor with the users input and
display its details using the toString method.
Ask the user how many cylinders they want to create and store them in an array of
BFCylinderB objects.
Use a loop to:
Create a cylinder object for each index in the array using the no args constructor.
Prompt the user for the radius and height of each cylinder.
Update the radius and height using the setter methods.
Display the details of each cylinder using get methods.
display the details of the first cylinder in the array using the toString method.
Sample Run:
Enter the radius of the cylinder:
Enter the height of the cylinder:
Using the parameterized constructor:
Surface area per square units
Volume per cubic units
for Radius: units
and Height: units
Using the toString method:
Surface area per square units
Volume per cubic units
for Radius: units
and Height: units
How many cylinders to create?
Enter the radius of cylinder :
Enter the height of cylinder :
Cylinder Details:
Radius:
Height:
Surface Area: per square units
Volume: per cubic units
Enter the radius of cylinder :
Enter the height of cylinder :
Cylinder Details:
Radius:
Height:
Surface Area: per square units
CIT Assignment B Chapter OOP Page
Volume: per cubic units
The first cylinder:
Surface area per square units
Volume per cubic units
for Radius: units
and Height: unit
Create set methods for surface area
Calculate the surface area:
Surface Areapi mathrmrmathrmrmathrmh where r is radius, h is height
Create a set method for Volume
Calculate the volume:
Volume pi mathrmrmathrm~h
Create a method to get the surface area and volume
Create an Override a toString method that will display Cylinder details
Radius, height, surface area, and volume.
Save the class as the following: your last and first initial with CylinderB for example if first Name Foo and last Name Bar the class name will be BFCylinderBjava
Create a class for testing that includes the main method, the class name will be LastNameFirstNameCitHwBjava
Prompt the user to enter the radius and height of the cylinder.
Create a cylinder object using the parameter constructor with the user's input and display its details using the toString method.
Ask the user how many cylinders they want to create and store them in an array of BFCylinderB objects.
Use a loop to:
Create a cylinder object for each index in the array using the no args constructor.
Prompt the user for the radius and height of each cylinder.
Update the radius and height using the setter methods.
Display the details of each cylinder using get methods.
display the details of the first cylinder in the array using the toString method.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
