Computer Science, asked by sweety5057, 1 year ago

write a Java program for function overloading by creating a function of calculate of volume of a cube, cylinder and rectangular prism

Answers

Answered by LonelyHeart
4
 <b> Hey friend ^_^

Here is your answer:

public class Function_Overloading
{
public static double volume (double h, double r)
{
double vcy = 22/7 * r * r * h;
return vcy;
}
public static double volume (double s)
{
double vcu = s * s * s;
return vcu;
}
public static void main (String args[])
{
double volumeCylinder = volume(24,6);
System.out.println(" Volume of the cylinder = "+ volumeCylinder);
double volumeCube = volume(64);
System.out.println(" Volume of the cube = "+ volumeCube);
}
}


Hope it helps u!
Similar questions