Print Star Pattern - 15 | Java Programs

Output:

*** Star Pattern 15 ***

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

Click Here For Java Online Compiler

Solution:

/**
 *
 * @author Alee Ahmed Kolachi
 */
public class StarPattern15 {

    private static void symbols(int count) {
        for (int i = 0; i < count; ++i) {
            System.out.print("*");
        }
    }

    private static void space(int count) {
        for (int i = 0; i < count; ++i) {
            System.out.print(" ");
        }
    }

    public static void main(String[] args) {

        int n = 6;
        System.out.println("     *** Star Pattern 15 ***" + "\n");
        for (int i = 0; i < n; ++i) {
            symbols(i + 1);
            space(n - i - 1);
            symbols(n - i + 1);
            space(2 * i);
            symbols(n - i);
            space(n - i - 1);
            symbols(i + 1);

            System.out.println();
        }
    }
}
Share This :

Related Post



sentiment_satisfied Emoticon