Friday 25 March 2016

Volume of Cube, Rectangular box and Cylinder

Code:


import java.util.*;

class volume
{
   
   void all(int a)
  {
      int k;
        k=a*a*a;
    
       System.out.println("volume of cube\t"+k);
      }
    void all(int b,int c)
  {
      int k;
      double pi=3.14;
      k=(int)(pi*(c*c)*b);
    
       System.out.println("volume of cylinder\t"+k);
      }
      void all(int d,int e,int f)
  {
      int k;
     
      k=d*e*f;
    
       System.out.println("volume of rectangular box\t"+k);
      }
 
  
   
}
class reca
{
public static void main(String[] args)
{
    int a,b,c,d,e,f;
    Scanner in=new Scanner(System.in);
      System.out.println("sides of cube");
    a=in.nextInt();
    volume obj=new volume();
  obj.all(a);
    System.out.println("height of cylinder");
   b=in.nextInt();
     System.out.println("radius of cylinder");
      c=in.nextInt();
    obj.all(b,c);
    System.out.println("rectangle box length");
 d=in.nextInt(); 
 System.out.println("rectangle box height");
 e=in.nextInt();
 System.out.println("rectangle box width");
 f=in.nextInt();
 obj.all(d,e,f);

}
}


Output:


No comments:

Post a Comment