Computer Science, asked by sprihag17, 8 months ago

4. Write a program to find sum of the volumes of box and cylinder using following
details :
In class Box
Members
Member variables
Member Method
Member's Name
Description
Double len, breadth, height, vol To store length, breadth,
height and volume
input(double 1,double b, double to accept length, breadth,
h)
height
To compute volume and store
volo
in variable vol
)
In class Cylinder
Members
Member variables
Member's Name
Double radius, height, vol
Description
To store radius, height and
volume
Member Method
input(double r, double h)
To accept radius, height
volo
To compute volume and
store in variable vol​

Answers

Answered by s15599aaayojita02024
1

Answer:

Cuboid is a 3-dimensional box-like figure represented in the 3-dimensional plane.Cuboid has 6 rectangled-shape faces. Each face meet another face at 90 degree each.Three sides of cuboid meet at same vertex.Since it is made up of 6 rectangle faces, it have length, width and height of different dimension.

cuboid

Examples :

Input : 2 3 4

Output : Area = 24

Total Surface Area = 52

Input : 5 6 12

Output : Area = 360

Total Surface Area = 324

Answered by Vivounavez
6

Answer:

class Computevol{

   void Addvol(Box v1, Cylinder v2){

       double vol = v1.vol + v2.vol;

       System.out.println("Sum of volumes = " + vol);

   }

   public static void main(){

       Computevol obj = new Computevol();

       Box v1 = new Box();

       Cylinder v2 = new Cylinder();

       v1.input(2,3,5);

       v2.input(3,4);

       v1.vol();

       v2.vol();

       obj.Addvol(v1,v2);

       

   }

}

class Box{

   double len,breadth,height,vol;

   void input(double l, double b, double h){

       len =l;

       breadth=b;

       height=h;

   }

   void vol(){

       vol = len*breadth*height;

       System.out.println("Volume of box =" + vol + "m3");

   }

}

class Cylinder{

   double radius, height, vol;

   void input(double r, double h){

       radius = r;

       height =h;

   }

   void vol(){

       vol = (22* radius * radius * height)/7;

       System.out.println("Vol of cylinder =" + vol + "m3");

   }

   }

Explanation:

Similar questions