Description: This program prints the following pattern:
********
*** ***
** **
* *
** **
*** ***
********
*** ***
** **
* *
** **
*** ***
********
Primary Inputs: None
Primary Output: The pattern specified above
Platform Used: JDK 1.6 with JCreator
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
class Pattern9 { public static void main(String args[]) { String s1 = "*"; int i, j, l = 8, x = 8, y = 8; for (int n = 0; n < 7; n++) { for (i = l / 2; i > 0; i--) { System.out.print(s1); } for (int k = 0; k < x - l; k++) { System.out.print(" "); } for (i = l / 2; i > 0; i--) { System.out.print(s1); } System.out.println(l + " " + x); if (y > 2) { l -= 2; y = l; } else l += 2; } } } |