Exercises with Loops

  1. Write a printTri( int n ) method that prints a right triangle of asterisks, whose size is n. For example, if n = 4, the output should be
    *
    **
    ***
    ****
    
  2. Write a printUpSideTri( int n ) method that prints an upside down right triangle of asterisks, whose size is n. For example, if n = 4, the output should be
    ****
    ***
    **
    *
    
  3. Write a printTri2( int n ) method that prints a right triangle of asterisks (with size n) , such that the right angle is at the lower right corner. For example, if n = 4, the output should be
       *
      **
     ***
    ****
    
  4. Write a printL( int h, int w ) method that prints the letter L using asterisks. h and w specify the length and width of the letter. For example, if h = 5 and w = 3, the output should be
    *
    *
    *
    *
    ***
    
  5. Write a printT( int h, int w ) method that prints the letter T using asterisks. h and w specify the length and width of the letter, where w is an odd number greater than 3. For example, if h = 6 and w = 5, the output should be
    *****
      *
      *
      *
      *
      *