Pattern 7 unable to print the square ! kindly help me with this

package PracticePattern;

import java.util.Scanner;

public class PracticePattern7 {

public static void main(String[] args) {
	// TODO Auto-generated method stub
	
	System.out.println("pattern 8 ");

	Scanner scan = new Scanner(System.in);
	int n = scan.nextInt();
	
	int rows=1;
	int nst=n;
	
	while(rows<=n)
	{
		for(int cst=1;cst<=nst;cst++)
		{
			if(rows==1||rows==n)
			{
				System.out.print("*");
			}
			else if(cst==1||cst==n)
			{
				System.out.print("*");
			}
			else
			{
				System.out.print(" ");
			}
		}
		
		//prep
		System.out.print("\n");
		nst++;
		rows++;
	}
	
}

}