Q:

Java patterns program 10

belongs to collection: Java programs to print patterns

0

Java program to print following pattern of series:

    **********
    ****  ****
    ***    ***
    **      **
    *        *
    *        *
    **      **
    ***    ***
    ****  ****
    **********

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

public class PrintPattern {
  public static void main(String args[]) {
    int space = 0;
    for (int i = 5; i >= 1; i--) {
      //print first part of the row
      for (int j = i; j >= 1; j--)
        System.out.print("*");

      //print space
      for (int j = 1; j <= space; j++)
        System.out.print(" ");

      //print second part of the row
      for (int j = i; j >= 1; j--)
        System.out.print("*");

      //print new lint
      System.out.println();
      space = space + 2;
    }

    space = 8;
    for (int i = 1; i <= 5; i++) {
      //print first part of the row
      for (int j = 1; j <= i; j++)
        System.out.print("*");

      //print space
      for (int j = 1; j <= space; j++)
        System.out.print(" ");

      //print second part of the row
      for (int j = 1; j <= i; j++)
        System.out.print("*");

      //print new lint
      System.out.println();
      space = space - 2;
    }

  }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

<< Java patterns program 9...