package javaRefresh; import java.util.Scanner; public class DiamandStructure { public static void main(String[] args) { //Take the input from the user Scanner scan = new Scanner(System.in); System.out.print("Enter no of Rows for Diamond Structure :"); int n = scan.nextInt(); int space = n - 1; //Create the first upper part of Diamond for (int i = 1; i <= n; i++) { for (int c = 1; c <= space; c++) { System.out.print("="); } space--; for (int c = 1; c <= (2 * i - 1); c++) { System.out.print("*"); } System.out.println(); } //============above part use as Pyramid structure ======== //Create the Second down part of Diamond space = 1; for (int d = 1; d <= (n - 1); d++) { for (int c = 1; c <= space; c++) { System.out.print("="); } space++; for (int c = 1; c <= (2 * (n - d) - 1); c++) { System.out.print("*"); } System.out.println(); } } }Output -
Enter Number of Rows for Diamond Structure : 4 ===* ==*** =***** ******* =***** ==*** ===*