04_Function-Overloading
04_Function-Overloading
class Schools
{
double area(double s)
{
return s*s;
}
}}
import java.util.* ;
class ICSE
{
rs1 = ob.area(s) ;
rs3 = ob.area(x, y, z) ;
}
Q> WaP using method-overloading to find the volume of a cube / cuboid /
cylinder depending on the user’s choice.
import java.util.*;
class Volumes
{
double vol(double s) // Cube
{
return s*s*s;
}
switch(ch)
{
case 1 : System.out.println("Enter the side of the Cube : ") ;
x = sc.nextDouble() ;
v = ob.vol(x) ;
System.out.println("Volume of the Cube = " + v) ;
break ;
}}