( --> )
Global Procedural Application Architecture
class LineOfSquaresApp
{
// declare variables
static private int nrSquares;
static private double lineArea;
static private double squareArea;
static private double squareSide;
static private int eeCount;
static private double perimeter;
// main method
static public void main (String args[])
{
readProblemParameters();
computeSingleSquareArea();
computeSingleSquareSide();
computeExternalEdgeCount();
computePerimeter();
displayPerimeter();
}
// other methods
static private void readProblemParameters()
{
IO.print("How many squares in the line? ");
nrSquares = IO.read_int();
IO.print("What is the area of the line of squares? ");
lineArea = IO.read_double();
}
static private void computeSingleSquareArea()
{
squareArea = lineArea / nrSquares;
}
static private void computeSingleSquareSide()
{
squareSide = Math.sqrt(squareArea);
}
static private void computeExternalEdgeCount()
{
eeCount = ( nrSquares * 2 ) + 2;
}
static private void computePerimeter()
{
perimeter = eeCount * squareSide;
}
static private void displayPerimeter()
{
IO.print("The perimeter of the line of squares is ");
IO.println(perimeter);
}
}