( --> )

Basic Application Architecture

class LineOfSquaresBAA
{
   static public void main (String args[])
   {
   // declare variables
      int nrSquares;      // nr of small squares
      double lineArea;    // area of line 
      double squareArea;  // area of one square
      double squareSide;  // side of one square
      int eeCount;        // nr of external edges 
      double perimeter;   // perimeter of line

   // read line length and area
      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();     

   // compute area of one square
      squareArea = lineArea / nrSquares;

   // compute side of one square
      squareSide = Math.sqrt(squareArea);     

   // compute number of external edges
      eeCount = ( nrSquares * 2 ) + 2;

   // compute perimeter of line of squares
      perimeter = eeCount * squareSide;   

   // display perimeter of line of squares
      IO.print("The perimeter of the line of squares is ");
      IO.println(perimeter); 
   }
}