WRITE A PROGRAM FOR FUNCTION OVERLOADING BY CREATING A FUNCTION CALLED vol() OF CALCULATE VOLUME OF A CUBE, CYLOINDER AND RECTANGULAR PRISM.
FORMULAE: VOLUME OF CUBE = side 3
VOLUME OF CYLINDER = π¬ x radius2 x height
VOLUME OF RECTANGULAR PRISM = length x width x height

1

Answers

The Brainliest Answer!
2015-06-18T13:55:53+05:30
Import java.util.*;
class Vol
{
float s, r, h, l, w, h1;
double cube, cylinder, prism;
Vol()
{
s=0;
r=0;
h=0;
l=0;
w=0;
h1=0;
cube=0;
cylinder=0
prism=0;
}
void input()
{
Scanner sn = new Scanner (System.in);
S.o.p("Enter side of the cube");
s=sn.nextFloat();
S.o.p("Enter radius of the cylinder");
r=sn.nextFloat();
S.o.p("Enter height of the cylinder");
h=sn.nextFloat();
S.o.p("Enter length of the rectangular prism");
l=sn.nextFloat();
S.o.p("Enter width of the rectangular prism");
w=sn.nextFloat();
S.o.p("Enter height of the rectangular prism");
h1=sn.nextFloat();
}
void calc()
{
cube = Math.pow(s,3);
cylinder = 3.14 * Math.pow(r,2) * h;
prism = l * w * h1;
}
void display()
{
S.o.p("Volume of the cube"+cube);
S.o.p("Volume of the cylinder"+cylinder);
S.o.p("Volume of the rectangular prism"+prism);
}
}
2 5 2