title: Functional Decomposition
body: <p>Hi I've wrote a program to print out a Diamond for a CS class; I've been asked to use function decomposition (global variables I think?) and I have no idea how to do this; some insight would help me out; my code isn't really pretty; but it does the job.</p>
  
  <pre><code>   public class SquareDiamondMid
   {
      public static void main(String args[]){
      System.out.println("printing Diamond");
      int number = BIO.getInt();
      int dotsTop = (number / 2) - 1;
      int count = 0;
      int LineN = 1;
      int DotsMiddle = 0;
      int mainCount = (number / 2)+1;
      int count1 = 0;
      int dot = (number / 2) - 1;
  
      while(count1&lt;=dot){
          System.out.print(".");
          count1 = count1 + 1;
      }
      System.out.print("*");
      count1 = 0;
      while(count1&lt;=dot){
          System.out.print(".");
          count1 = count1 + 1;
      }
      System.out.println(""); 
  
      while(mainCount&lt;number){
          while(count&lt;dotsTop){
              System.out.print(".");
              count++;
          }
          System.out.print("*");
          while(DotsMiddle&lt;LineN){
              System.out.print(".");
              DotsMiddle++;
          }
          System.out.print("*");
          count = 0;
          while(count&lt;dotsTop){
              System.out.print(".");
              count++;
          }
          System.out.println("");
          LineN = LineN + 2;
          DotsMiddle = 0;
          dotsTop--;
          mainCount++;
          count=0;
      }
      //bottom
      int bottomLineN=1;
      int numberOfBottom = (number / 2) - 2;
      int bottomCount = 0;
      int mainBottomCount=0;
      int bottomMidCount = 0;
      int bottomMidDot = number - 4;
      int bottomCount2 = 0;
  
      while(mainBottomCount&lt;=numberOfBottom){
  
          while(bottomCount&lt;bottomLineN){
              System.out.print(".");
              bottomCount++;
          }
          System.out.print("*");
          while(bottomMidCount&lt;bottomMidDot){
              System.out.print(".");
              bottomMidCount++;
          }
          System.out.print("*");
  
          while(bottomCount2&lt;bottomLineN){
              System.out.print(".");
              bottomCount2++;
          }
  
          bottomCount2 = 0;
          bottomMidCount = 0;
          bottomMidDot = bottomMidDot - 2;
          System.out.println("");
          mainBottomCount++;
          bottomCount=0;
          bottomLineN = bottomLineN + 1;
      }
  
      int count3=0;
      while(count3&lt;=dot){
          System.out.print(".");
          count3 = count3 + 1;
      }
      System.out.print("*");
      count3 = 0;
      while(count3&lt;=dot){
          System.out.print(".");
          count3 = count3 + 1;
      }
      System.out.println(""); 
  }
  </code></pre>
  
  <p>Thanks in advance`.</p>