Computer Science, asked by khushboo6770, 11 months ago

Design a class to overload a function volume () as follows:1.double volume (double r): with radius (r) as an argument,returns the volume sphere using 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 the volume of cylinder using formula V=22/7*r*r*h3. the volume of cuboid using formula V=l*b*h​

Answers

Answered by sswaraj04
40

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);

   }

}

Explanation:

*try on first bcoz later u will find much logical programming

*check for any syntax error!!

*u can add ...println to print volume found

Answered by adityaksantosh3105
8

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);

  }

}

Explanation:

i have none

Similar questions