In this Tutorial we are going to write a program that prints Complete pyramid . see the below example.

import java.util.Scanner;
public class CompletePyramid {
        public static void main(String[] args) {
			    System.out.print("Please Enter Pyramid size: ");
                Scanner read = new Scanner(System.in);
                int size = read.nextInt();
                for (int i = 1; i <= size; i++) {
                    for (int j = size; j >= i; j--) {
                              System.out.print(" ");
                        }
				    for (int k = 1; k <= i; k++) {
                              System.out.print("* ");
                        } 
               System.out.println("");
              }
    }     
}
 
/*
=======Output========

 Please Enter Pyramid size: 6
      *
     * *
    * * *
   * * * *
  * * * * *
 * * * * * *

Leave a Reply

Your email address will not be published. Required fields are marked *