Economics / Money

Create a user-defined package box which has a class definition. For box having data member and disp( ) method

By Rabins Sharma Lamichhane

June 11, 2017

Write a JAVA program to accomplish the following task.

  1. Create a user-defined package box which has a class definition. For box having data member and disp( ) method. (Assume suitable data).
  2. 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(); } }

 

Share this: