Sir code is working perfect but submission problem

public static void main(String[] args) {

	Scanner scn = new Scanner(System.in);
	int n = scn.nextInt();
	int nst = 1;
	int nsp = n / 2;
	int nst2 = 1;
	int row = 1;
	int nsp2 = n / 2;
	int nst3 = 1;
	while (row <= n) {
		if (row == 1) {
			nst3 = nst + n / 2;
		} else if (row == n / 2 + 1) {
			nst3 = nst + n / 2;
			nst = nst + n / 2;

		} else if (row == n) {
			nst = nst + n / 2;

		}

		else {
			nst = 1;
			nst = 1;
			nst3 = 1;

		}
		int cst = 1;
		while (cst <= nst) {
			if (row <= n / 2+1 || row == n) {
				System.out.print("*");
				cst++;

			} else {
				System.out.print(" ");
				cst++;
			}

		}
		int csp = 1;
		while (csp <= nsp) {

			if (row == n / 2 + 1 || row == n) {
				csp++;
			} else {
				System.out.print(" ");
				csp++;
			}

		}
		cst = 1;
		while (cst <= nst2) {

			System.out.print("*");
			cst++;

		}
		csp = 1;
		while (csp <= nsp2) {
			if (row == 1 || row == n / 2 + 1) {
				csp++;
			} else {
				System.out.print(" ");
				csp++;
			}

		}
		cst = 1;
		while (cst <= nst3) {
			if (row == 1 || row >= n / 2 + 1) {
				System.out.print("*");
				cst++;

			} else {
				cst++;
			}

		}
		System.out.println();

// if(row==1 || row==n/2) {
//
//
// }
row++;

	}
}

}

@deepgarg46 Your code looks fine to me. Don’t worry the question is such that it will take tedious amount of loops if conditions.

why show error on submission time

@deepgarg46 You are not getting any error but your answer is wrong you need to print n stars on centreline but your code is printing n+2 stars. Solve this problem