You are on page 1of 5

Assignment Submission Deadline: 10th October 2012 (Monday lab) & 14th October 2012 (Friday lab) Instruction

Work in a group of two. Question Implement class Sphere, Cylinder and Cone with the following methods. In the class Geometry, prompt the user for values of radius and height and computes the volume and surface area of a sphere with radius r, a cylinder with radius r and height h, and a cone with radius r and height h.
import java.util.Scanner; /** This is a test class for the Sphere, Cylinder, and Cone class */ public class Geometry { public static void main(String[] args) { //Please enter the radius: //Please enter the height: //The volume of the sphere is: //The surface area of the sphere is: //The volume of the cylinder is: //The surface area of the cylinder is: //The volume of the cone is: //The surface area of the cone is: } }

/** This class provides methods to compute the volume and surface area of a sphere. */ public class Sphere { /** Constructs a Sphere object with input: radius @param aRadius the radius */ public Sphere(double aRadius) { } /** Computes the volume of a sphere. @return volume of sphere */ public double getVolume() { } /** Computes the surface area of a sphere. @return surface area of a sphere */ public double getSurfaceArea() { } }

/** This class provides methods to compute the volume and surface area of a cylinder. */ public class Cylinder { /** Constructs a Cylinder object with input: radius and height. @param aRadius the radius @param aHeight the height */ public Cylinder(double aRadius, double aHeight) { } /** Computes the volume of a cylinder. @return volume of a cylinder */ public double getVolume() { } /** Computes the surface area of a cylinder. @return surface area of a cylinder */ public double getSurfaceArea() { } }

/** This class provides methods to compute the volume and surface area of a cone. */ public class Cone { /** Constructs a Cone object with input: radius and height. @param aRadius the radius @param aHeight the height */ public Cone(double aRadius, double aHeight) { } /** Computes the volume of a cone. @return volume of a cone */ public double getVolume() { } /** Computes the surface area of a cone. @return surface area of a cone */ public double getSurfaceArea() { } }

Marks distribution:

Assessment Criteria

Marks

Compilation (no errors and executable) Program implementation Test class (3) Class Sphere (3) Class Cylinder (3) Class Cone (3) Coding style (e.g:display of output)

12

Total

15

Deliverables: All students must complete and present your program during the lab session.

You might also like