Source of Question3.java


  1: //Question3.java
  2: 
  3: public class Question3
  4: {
  5:     public static void main(String[] args)
  6:     {
  7:         displaySharps(3);
  8:     }
  9: 
 10:     /**
 11:      * Precondition: n >= 1.
 12:      * Displays the symbol '#' n times on one line
 13:      * and then advances to the next line.
 14:      */
 15:     public static void displaySharps
 16:     (
 17:         int n
 18:     )
 19:     {
 20:         if (n <= 1)
 21:             System.out.println('#');
 22:         else
 23:         {
 24:             System.out.print('#');
 25:             displaySharps(n - 1);
 26:         }
 27:     }
 28: }