Question 19: Second row is having stars more than n. Output is not correct

package PatternsQuestions;

import java.util.Scanner;

public class ques19 {

public static void main(String[] args) {
	Scanner scn = new Scanner(System.in);
	int n = scn.nextInt();
	
	//setting initial values
	int nst = n/2;
	int nsp = 1;
	
	//setting for loop
	for(int row = 1; row<=n; row++) {
		
		//work
		if(row==1 || row ==n) {
			for(int count = 1; count<=n; count++) {
				System.out.print("*");
			}
		} else {
			for(int cst=1; cst<= nst; cst++) {
				System.out.print("*");
			}
			
			for(int csp=1; csp<=nsp; csp++) {
				System.out.print(" ");
			}
			
			for(int cst=1; cst<= nst; cst++) {
				System.out.print("*");
		}
			
		}
		
		//prep
		//setting up if statement for rows greater than 1 
		// and less than or = n/2 (3 in this case)
		System.out.println();
		if(row >=2 && row <=n/2) {
			nst--;
			nsp+=2;
		} else {
			nst++;
			nsp-=2;
		}

}
	scn.close();

}}