Build a Sphere Class
mediumQuestion 149Complete the Sphere class with: a constructor that stores the radius, getRadius(), setRadius(double r), getVolume() using (4/3)π*r³, getSurfaceArea() using 4π*r², and toString() that returns the formatted string with radius, volume, and surface area each rounded to 2 decimals.
The toString() method should return a string in the exact format shown in Expected Output.
Use String.format("%.2f", value) for formatting.
Do NOT write a main method.
Expected output
Radius: 5.00 Volume: 523.60 Surface area: 314.16
= newline. The output ends with a newline, so print one after the last line.
Hints4 available
Sign in to use hintsTopics
Classes
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (sysout, psvm, fori)
Your output
Run your code to see the output here...
Test cases
Run your code to see test case results.