Write a java program to print following pattern
import java.util.Scanner;
public class StarPattern12 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("Enter Size: ");
int n=sc.nextInt();
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if(i==0 || i==n-1 || i==j || i==n-j-1 )
System.out.print("* ");
else
System.out.print(" ");
}
System.out.println();
}
}
}
Comments
Post a Comment