Diamond of Stars
Pattern for N = 5 import java.util.Scanner; public class DiamondOfStars { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n= s.nextInt(); int f=n/2; int l=n-f; int sp=f; for(int i=1;i<=f;i++) { for(int k=1;k<=sp;k++) { System.out.print(" "); } sp--; for(int j=1;j<=2*i-1;j++) { System.out.print("*"); } System.out.println(); } int space = 1; for(int i=l;i>=1;i--) { for(int k=1;k<space;k++) { System.out.print(" "); } space++; for(int j=1;j<=2*i-1;j++) { System.out.print("*"); } System.out.println(); } } }