1.

Write a program to create a class called box and calculate its volume by calling its method.

Answer»

import java.util. *;

class box

{

public double volume(double x, double y, double z)

{

double vol=x*y*z;

RETURN vol;

}

public VOID main ()

{

Scanner sc=new Scanner (System.in);

System.out.println ("Enter LENGTH, breadth and height") ;

double l=sc.nextDouble();

double b=sc.nextDouble();

double H=sc.nextDouble();

System.out.println ("Volume =" +volume(l, b, h)) ;

}

}



Discussion

No Comment Found