Print Star Pattern - 7 | Java Programs

Output:

*** Star Pattern 7 ***

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

Click Here For Java Online Compiler

Solution:

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

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

Related Post



sentiment_satisfied Emoticon