( --> )
Functional Application Architecture
class LineOfSquaresFAA
{
// main method
static public void main (String args[])
{
int nrSquares = readSquareLength();
double lineArea = readLineArea();
double squareArea = squareArea(lineArea, nrSquares);
double squareSide = squareSide(squareArea);
int eeCount = eeCount(nrSquares);
double perimeter = perimeter(squareSide, eeCount);
IO.print("The perimeter of the line of squares is ");
IO.println(perimeter);
}
// other methods
static private int readSquareLength()
{
IO.print("How many squares in the line? ");
return IO.read_int();
}
static private double readLineArea()
{
IO.print("What is the area of the line of squares? ");
return IO.read_double();
}
static private double squareArea(double la, int n)
{
return ( la / n );
}
static private double squareSide(double sa)
{
return Math.sqrt(sa);
}
static private int eeCount(int n)
{
return ( ( n * 2 ) + 2 );
}
static private double perimeter(double ss, int ee)
{
return ( ss * ee );
}
}