( --> )

Local Procedural Application Architecture

class LineOfSquaresLPAA
{

// main method
   static public void main (String args[])
   {
      IntAtom nrSquares = new IntAtom();         
      DoubleAtom lineArea = new DoubleAtom();   
      DoubleAtom squareArea = new DoubleAtom();  
      DoubleAtom squareSide = new DoubleAtom();  
      IntAtom eeCount = new IntAtom();          
      DoubleAtom perimeter = new DoubleAtom();   

      readProblemParameters
         (nrSquares, lineArea);
      computeSingleSquareArea
         (squareArea, lineArea.value(), nrSquares.value() );
      computeSingleSquareSide
         (squareSide, squareArea.value());
      computeExternalEdgeCount
         (eeCount, nrSquares.value());
      computePerimeter
         (perimeter, squareSide.value(), eeCount.value());
      displayPerimeter
         (perimeter.value());
   }

// other methods

   static private void readProblemParameters
      (IntAtom ns, DoubleAtom la)
   {
      IO.print("How many squares in the line? ");
      ns.setValue(IO.read_int());   
      IO.print("What is the area of the line of squares? ");       
      la.setValue(IO.read_double());  
   }
      
   static private void computeSingleSquareArea
      (DoubleAtom sa, double la, int ns)
   {
      sa.setValue(la / ns);
   }
      
   static private void computeSingleSquareSide
      (DoubleAtom ss, double sa)
   {
      ss.setValue(Math.sqrt(sa));     
   }
      
   static private void computeExternalEdgeCount
      (IntAtom ee, int ns)
   {
      ee.setValue(( ns * 2 ) + 2);
   }
      
   static private void computePerimeter
      (DoubleAtom p, double ss, int ee)
   {
      p.setValue(ee * ss);   
   }
      
   static private void displayPerimeter
      (double p)
   {
      IO.print("The perimeter of the line of squares is ");
      IO.println(p); 
   }
            
}