public class Box double length double width double height B
public class Box
{
double length;
double width;
double height;
Box(double l, double w, double h)
{
length = l;
width = w;
height = h;
}// Box( )
double volume( )
{
return length * width * height;
}// end volume( )
}// end class Box
8.Write a statement to output the volume of the blue box.
Solution
Answer:
Box b=new Box();
System.out.println(\"Volume of Box is\"+b.volume());
fullprogram:
/* package whatever; // don\'t place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
class Box
{
double length;
double width;
double height;
Box(double l, double w, double h)
{
length = l;
width = w;
height = h;
}// Box( )
double volume( )
{
return length * width * height;
}// end volume( )
}// end class Box
/* Name of the class has to be \"Main\" only if the class is public. */
class Ideone
{
public static void main (String[] args) throws java.lang.Exception
{
Box b=new Box();
System.out.println(\"Volume of Box is\"+b.volume());
}
}

