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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!