Print Star Pattern - 13 | Java Programs

Output:

*** Star Pattern 13 ***

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

Click Here For Java Online Compiler

Solution:

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

    public static void main(String[] args) {
        int rows = 6;
        System.out.println("*** Star Pattern 13 ***" + "\n");

        for (int i = 0; i < rows; ++i) {
            for (int j = 0; j <= i; ++j) {
                System.out.print("*");
            }

            if (i != rows - 1) {
                System.out.print(" ");
            } else {
                System.out.print(" *");
            }
            for (int j = 0; j <= i; ++j) {
                System.out.print("*");
            }

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

Related Post



sentiment_satisfied Emoticon