Wednesday, February 4, 2009

CUBE

/* Programmer : Dandy A. Macaubos
     Program name : Cube
     Date Started : February 4,2009
    Date Finished : February 4,2009
    Purpose : To have a program using encapsulation
    Instructor : Dony Dongiapon
    Subject : IT134
*/

import javax.swing.JOptionPane;
 
  public class Cube{

 private double width;
 private double height;
 private double lenght;
 
  public Cube(double wid, double heigh, double len)
 {
 this.width=wid;
 this.height=heigh;
 this.lenght=len;
 }
  private Cube()
 {
 
 }
 
  public void SetDimension(double newwidth, double newheight, double newlength)
 {
 this.width=newwidth;
 this.height=newheight;
 this.lenght=newlength;
 }
 
 
  private double volume(){
 return width*lenght*height;
  }

  private double area(){
 return width*lenght;
  }
 

  public String displayCube(){
 return String.format(volume()+" and "+area());
  }

}
 
 
/* Programmer : Dandy A. Macaubos
     Program name : Cube
     Date Started : February 4,2009
     Date Finished : February 4,2009
     Purpose : To have a program that uses  encapsulation
     Instructor : Dony Dongiapon
     Subject : IT134
*/

import javax.swing.JOptionPane;

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

 double width;
 double height;
 double length;

 width=Integer.parseInt(JOptionPane.showInputDialog("Enter width value"));
 height=Integer.parseInt(JOptionPane.showInputDialog("Enter the value of the height"));
 length=Integer.parseInt(JOptionPane.showInputDialog("Enter the value of the length"));

 
 
 }
}