Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  Rect1.java
Language: JAVA
Code:
public class Rect1
{
    double width;
    double height;
    double depth;
    // constructor for the program
    Rect1(double w,double h,double d){
        width =w;
        height = h;
        depth = d;
    }
    //method for calculating volume
    double volume(){
        double vol= w * h * d;
        return vol;
    }
public class Rect1Test{
    public static void main(string  args[]){
        Rect1 a = new Rect1(9.8796,5.7658,8.7423);
        Rect2 b = new Rect1(2.7895,5.2398,7.9548);
        //invoking volume method on a
        system.out.println("the volume is" + a.volume());
        system.out.println("the volume is " + b.volume());
        
    }
}
}          
Comments: