Tuesday, February 3, 2009

IT134 Cube Solutions

//Programmer: Jeanne B. Ramos
//Date started: February 4, 2009
//Date ended: February 6, 2009
//Programmed name: Cube Exe
//Purpose: To create classes using Visibility Modifiers

 public class Cubez{    private double volume;
    private double area;
    private double width;
    private double height;
    private double length;
    private double setDimension;

public Cubez(){
    width=0;
    height=0;
    length=0;
    volume=0;
    area=0;
    }
    public Cubez(double width,double height,double length){
this.width=width;
this.height=height;
this.length=length;
    
    }
public void setDimension(double newwidth, double newheight, double newlength){
    this.width=width;
this.height=height;
this.length=length;
    }
    

    public void displayArea(){
System.out.println(length*width);}
public void dispalyVolume(){
    System.out.println(length*width*height);
}

}





//Programmer: Jeanne B. Ramos
//Date started: February 4, 2009
//Date ended: February 6, 2009
//Programmed name: Cube Exe
//Purpose: To create classes using Visibility Modifiers

public class CubeTest{
    public static void main(String[]args){

        Cube1 A=new Cube1();
        Cube1 B=new Cube1(5, 6, 10);

    A.setDimension(1,4,5);
    A.getvolume();
    A.getarea();
        System.out.println("Cube A" +"\t="+A.getvolume());
        System.out.println("Cube A"+"\t="+A.getarea());
    B.setDimension(4,6,8);
    B.getvolume();
    B.getarea();
        System.out.println("Cube B"+"\t="+B.getvolume());
        System.out.println("Cube B"+"\t="+B.getarea());
    }
}





No comments:

Post a Comment