Sphere - Returns the calculated value of the volume-public...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//****************************************************************************** // Sphere.java Author: Lewis/Loftus // // Represents a sphere. //****************************************************************************** / public class Sphere extends Circle { //--------------------------------------------------------------------------- // Sets up the sphere by entering its radius //--------------------------------------------------------------------------- public Sphere(double rad) { super(rad); } //--------------------------------------------------------------------------- // Returns the calculated value of the surface area //--------------------------------------------------------------------------- public double computeArea() { return 4 * super.computeArea();
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: } //---------------------------------------------------------------------------// Returns the calculated value of the volume //---------------------------------------------------------------------------public double computeVolume() { return Math.pow(radius, 3) * Math.PI * 4 / 3; } //---------------------------------------------------------------------------// Returns pertinent information about the sphere //---------------------------------------------------------------------------public String toString() { return "Sphere: radius is " + form.format(radius) + "\ncircumference is " + form.format(computePerimeter()) + ", area is " + form.format(computeArea()) + "\nvolume is " + form.format(computeVolume()) + "\n"; } }...
View Full Document

Ask a homework question - tutors are online