



|
|
Byron's CSC212 Web Site
|
Programming Challenge Archive
General Problems Solving ( Basic Programming Apps )
Columns of Cubes
|
|
|
JavaApplication --
Columns of Cubes
// General Information
// ---------------------------------------------------
// File: ColumnOfCubesApp.java
// Type: java application file
// Date: Wed Sep 20, 2000
// Name: Byron Bahr
// Line: Compute the Volume of a Column
// Application Description
// ---------------------------------------------------
/*
Stack five cubes in a colume, compute the volume of
the structure if the surface area is 587.785
*/
// Required Packages
// ---------------------------------------------------
import blue.io.*;
// Application Class
// ---------------------------------------------------
class ColumnOfCubesApp
{
static public void main (String args[])
{
// Define Known Values
int cubesStacked = 5;
double surfaceAreaStructure = 587.785;
int cubeFaces = 22;
// Compute the area of each face
double areaCubeFace =
surfaceAreaStructure / cubeFaces;
//Compute the length of the side of each cube
double lengthCubeSide =
Math.pow (areaCubeFace,0.5);
//Compute the Volume of the Column
double heightColumn =
cubesStacked * lengthCubeSide;
double volumeColumn =
lengthCubeSide *
lengthCubeSide *
heightColumn;
//Display Results
IO.print ("The Volume of the Column is ");
IO.print (volumeColumn);
IO.print (" feet.");
IO.println ();
}
}
// Demo
// -------------------------------------------------
/*
The Volume of the Column is 690.5000771358459 feet.
*/
|
|
|