Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The first picture is the Sphere calculation from my lab 4, please help beaded on that! Thank you 1130 LabSphereCal.java ols Project Debugger Language Level
The first picture is the Sphere calculation from my lab 4, please help beaded on that! Thank you
1130 LabSphereCal.java ols Project Debugger Language Level Help d Open save [4 Close Cut Copy Paste Undo import java.util. Scanner: public class SphereCal ( public static void main(Stringt] args) f int angles: double volume, surfacerea,pi-3. 14: Scanner scan-nev Scanner (System. in): /'Read the radius from the user- "/ System. out.print("Enter radius ) radius-scan.nextInt; volume- (4.0/3.0) pi radius radius radius; surfaceArea 4mi * ( radius * radius ) ; System. out.print("Volume "+lume); Systen. out.printi"Surface Area :"+surfaceArea): Console Compiler Output eady: UDK 8.0 172 from C:NProgram 2. Re-work your solution for the Sphere calculations from Lab 4, PP 3.5, Page 107, to 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 as well. e. Note: The volume and surface area will be done through accessors (Do NOT store these values from the constructor). f. Define a helper method name checkDiameter. The functional of this helper method is to ensure that the diameter entered is not less than zero. If the diameter is less than zero, set it to zero. g. 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 i. 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 ii. Sphere 3: 50.0 iv. Sphere 4: 100.0 Your output should be EXACTLY as shown below: Original spheres diameters Sphere 1 original values: Sphere diameter: 10.0 Volume: 523.599 Area: 314.159 Sphere 2 original values: Sphere diameter: 20.0 Volume: 4188.79 Area: 1256.637 Sphere 3 original values: Sphere diameter: 11.946 Volume: 892.619 Area: 448.327 Sphere 4 original values: Sphere diameter: 0.0 Volume: 0 Area: 0 Resetting spheres diameters: Sphere 1 new values: Sphere diameter: 5.0 Volume: 65.45 Area: 78.54 Sphere 2 new values: Sphere diameter: 25.0 Volume: 8181.231 Area: 1963.495 Sphere 3 new values: Sphere diameter: 50.0 Volume: 65449.847 Area: 7853.982 Sphere 4 new values: Sphere diameter: 100.0 Volume: 523598.776 Area: 31415.927 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