Write a JAVA program to accomplish the following task.
- Create a user-defined package box which has a class definition. For box having data member and disp( ) method. (Assume suitable data).
- Source file imports above package and calculates the volume of the box.
import java.lang.*;
import java.io.*;
Pacakage BoxPackage
{
public class Box
{
int length, breadth, height;
Box(int I,int b,int h)
{
length=l;
breadth=b;
height=h;
}
public void display()
{
int volume=length*breadth*height;
System.out.println("Volume of Box is"+volume);
}
}
}
import.BoxPackage.*;
class Boxdemo
{
public static void main(string args[])
{
Box b=new Box(10,20,30);
b.display();
}
}

Leave a Reply