06-04-2011, 01:15 PM
Code:
import java.io.*;
class Vroom
{
int length,width,height;
Vroom()
{
length=width=height=0;
}
Vroom(int l,int w,int h)
{
length=l;
width=w;
height=h;
}
Vroom(Vroom v)
{
length=v.length;
width=v.width;
height=v.height;
}
int volume()
{
return(length*width*height);
}
}
class Newv
{
public static void main(String args[])throws IOException
{
DataInputStream dis=new DataInputStream(System.in);
System.out.println("enter the length");
int i=Integer.parseInt(dis.readLine());
System.out.println("enter the width");
int j=Integer.parseInt(dis.readLine());
System.out.println("enter the height");
int k=Integer.parseInt(dis.readLine());
Vroom v1=new Vroom(i,j,k);
int vol=v1.volume();
System.out.println("Volume="+vol);
}
}
OUTPUT
E:\vee>java New
enter the length
2
enter the width
3
enter the height
4
Volume=24