Question
That is Java project, work your solution for the Sphere calculations from an Object-Oriented solution. a. Define a Sphere class, named Sphere.java with a diameter
That is Java project, work your solution for the Sphere calculations from an Object-Oriented solution.
a. Define a Sphere class, named Sphere.java with a diameter instance variable [Note: NOT radius].
b. A default constructor that sets the diameter to zero.
c. A constructor that takes in a diameter value.
d. Define get and set methods for the diameter.
e. Note: The volume and surface area MUST be done through accessors (DO NOT store these values from the constructor).
f. Define a helper method name checkDiameter, that ensures the diameter of the sphere is not less than zero. If the diameter is less than zero, the helper method should set the diameter to zero.
g. Completely test the functional of your class by creating a driver named MultiSphere.java.
h. Demonstrate using test cases for spheres having the following diameters and rounding your values of areas and volumes to three decimal places.
i. Sphere 1: 10.0 ii. Sphere 2: 20.0 iii. Sphere 3: 11.946 iv. Sphere 4: -9.99
i. Reset the diameters of the above spheres to:
i. Sphere 1: 5.0 ii. Sphere 2: 25.0 iii. Sphere 3: 50.0 iv. Sphere 4: 100.0
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