



|
|
CS1 Course Site
|
Programming Challenge Archive
General Problems Solving
Columns of Cubes
|
|
|
JavaApplication --
ColumnsOfCubes
// General Information
// ---------------------------------------------------
// File: ColumnsOfCubesApp.java
// Type: java application file
// Date: Tue Sep 19, 2000
// Name: Kara Becker
// Line: Compute the volume of the structure.
// Application Description
// ---------------------------------------------------
/*
Determine the volume of a structure with the given informa+
tion.
*/
// Required Packages
// ---------------------------------------------------
import blue.io.*;
// Application Class
// ---------------------------------------------------
class ColumnsOfCubesApp
{
static public void main (String args[])
{
//Determine the volume of one side of the structure.
double sa = 587.785;
int nrSides = 22;
double volOneSide = sa / nrSides;
//Determine the length and width of one cube.
double oneCube = Math.sqrt(volOneSide);
//Determine the volume of one cube.
double volOneCube = Math.pow(oneCube,3);
//Determine the total volume of the structure.
int nrCubes = 5;
double totalVolume = volOneCube * nrCubes;
//Display the results.
IO.print("The volume of the column is ");
IO.print(totalVolume);
IO.print(" feet.");
IO.println();
}
}
// Demo
// ---------------------------------------------------
/*
$ javac ColumnsOfCubesApp.java
$ java ColumnsOfCubesApp
The volume of the column is 690.5000771358459 feet.
$
*/
|
|
|