Method Deck / geometry

Sphere and cylinder volume and surface area

Computes the volume and total surface area of a sphere or a right circular cylinder.

Published for review. The Founder is checking every card himself; anything he strikes comes down the same hour.

Try it

Inputs

Outputs

Steps

  1. For a sphere of radius r: volume = (4/3) * pi * r^3; surface area = 4 * pi * r^2.
  2. For a right circular cylinder of radius r and height h: volume = pi * r^2 * h; total surface area = 2*pi*r*h + 2*pi*r^2 (the side plus both circular ends).
  3. Round both results to 2 decimals.

Constants

Sources

Worked example and test vectors

NameInputsAnswer
worked example{"shape":"sphere","radius":3}volume 113.10, surface area 113.10
test vector: cylinder{"shape":"cylinder","radius":2,"height":5}volume 62.83, surface area 87.96

Published card