Design a java class to overload a function volume() as follows:-
i) void volume( int s) computes the volume of a cube.
ii) void volume(float r) computes the volume of a sphere.
iii) void volume(int l,int b,int h) computes the volume of a cuboid
Answers
Answered by
0
Answer:
KnowledgeBoat Logo
Computer Applications
Design a class to overload a function volume( ) as follows:
1. double volume(double r) — with radius (r) as an argument, returns the volume of sphere using the formula:
V = (4/3) * (22/7) * r * r * r
2. double volume(double h, double r) — with height(h) and radius(r) as the arguments, returns the volume of a cylinder using the formula:
V = (22/7) * r * r * h
3. double volume(double 1, double b, double h) — with length(l), breadth(b) and height(h) as the arguments, returns the volume of a cuboid using the formula:
V = l*b*h ⇒ (length * breadth * height)
Similar questions