Design a class to overload a function volume ()as follows:i-double volume (double r)with one double argument,return the volume of a sphere a cone using the formula:volume =1/3*pi*r*r*h
Answers
Answered by
2
Answer:
class JavaExample
{
double volume(double r)
{
double V=4/3*22/7*r*r*r;
return V;
}
double volume(double h,double r)
{
double V=22/7*r*r*h;
return V;
}
double volume(double l,double b,double h)
{
double V=l*b*h;
return V;
}
public static void main(String args[]){
JavaExample obj = new JavaExample();
double x=obj.volume(6.1);
double y=obj.volume(10.05,22.2);
double z=obj.volume(6.1,2.5,9.5);
}
*try on first bcoz later u will find much logical programming
*check for any syntax error!!
*u can add ...println to print volume found
Explanation:
please thank me and mark me as brainliest.
Similar questions