Wednesday, February 4, 2009

IT134A_DDS

/*Programmer: Gezelle Re-ann B. Mandabon
/*Date started: 02-04-2009
/*Date ended: 02-04-2009
/*Program name: Cube
/*Program purpose: To create classes using Visibility Modifiers.

public class Cube
{
private double length;

private double width;
private double height;
private double volume;
private double area;

public Cube(double l, double w, double h)

{

l=length;

w=width;

h=height;

}

public Cube()

{

}

private double volume()

{
return (length*width*height);

}


private double area()

{

return (length*width);

}

public void setDimension(double newLength, double newwidth, double newheight)

{

length=newLength;

width=newWidth;

height=newHeight;

}


public void displayCube()

{

System.out.println("Cube Dimensions");

System.out.println("The VOLUME of the Cube is" +volume());

System.out.println("The AREA of the Cube is" +area());

}

}

***************************************************************************

/*Programmer: Gezelle Re-ann B. Mandabon

/*Date started: 02-04-2009

/*Date ended: 02-04-2009

/*Program name: CubeTester

/*Program purpose: To create classes using Visibility Modifiers.

import java.util.Scanner;

class CubeTester

{

public static void main(String args[])

{

double l;

double w;

double h;


System.out.println("\n\n");

System.out.println("The Cube object with a parameter");

Cube firstCube=new Cube(2,2,2);

firstCube.displayCube();

System.out.println("The Cube object without a parameter");

System.out.println("\n\n");

Scanner a=new Scanner(System.in);

System.out.println("enter the value of the length:");

l=a.nextDouble();

Scanner b=new Scanner(System.in);

System.out.println("enter the value of the height:");

w=b.nextDouble();

Scanner c=new Scanner(System.in);

System.out.println("enter the value of the width:");

h=c.nextDouble();

System.out.println("The Cube object without a parameter");

System.out.println("\n\n");

Cube secondCube=new Cube();

secondCube.setDimension(l,w,h);

secondCube.displayCube();

}

}

************************nothing follows***************************

No comments:

Post a Comment