ICSE Computer Science Java Programs | IT Developer
IT Developer

Java Programs - Solved 2008 ICSE Computer Science Paper



Share with a Friend

Solved 2008 ICSE Computer Science Paper

Class 10 - ICSE Computer Science Solved Papers

Function Overloading - Volume Program - ICSE 2008 Computer Science

Write a class with the name Volume using function overloading that computes the volume of a cube, a sphere and a cuboid.
Formula:
volume of a cube (vc) = s * s * s.
volume of a sphere (vs) = 4 / 3 * π * r * r * r where π = 3.14 or 22 / 7.
volume of a cuboid (vcd) = l * b * h.

class Volume{ public static double volume(double s){ return Math.pow(s, 3); } public static double volume(double pi, double r){ return 4.0 / 3 * pi * Math.pow(r, 3); } public static double volume(double l, double b, double h){ return l * b * h; } }

Output