Print Star Pattern - 3 | Java Programs

Output:

*** Star Pattern 3 ***

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

Click Here For Java Online Compiler

Solution:

class StarPattern3 {

    public static void main(String args[]) {
        int rows = 7;
        System.out.println("*** Star Pattern 3 ***" + "\n");
        for (int i = 1; i < rows; i++) {
            for (int j = rows; j > i; j--) {
                System.out.print(" ");
            }
            for (int j = 1; j <= i * 2 - 1; j++) {
                System.out.print("*");
            }
            System.out.println("");
        }
    }
}
Share This :

Related Post



sentiment_satisfied Emoticon