Ganesha pattern

import java.util.Scanner;

public class GaneshaPattern {

public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int nst =N;
	int nst1 = 1;
	int nsp1 = 2;
	int nst2 = N - 4;
	
	//row work
	int row = 1;
	while(row<=N)
	{
		if(row<=N/2)
		{
			for(int cst1=1;cst1<=nst1;cst1++)
			{
				System.out.print("*");
			}
			for(int csp1 = 1;csp1<=nsp1;csp1++)
			{
				System.out.print(" ");
			}
			for(int cst1=1;cst1<=nst1;cst1++)
			{
				System.out.print("*");
			}
			for(int cst2 = 1;cst2<=nst2;cst2++)
			{
				if(row==1)
				{
					System.out.print("*");
				}
				else
				{
					System.out.print(" ");
				}	
			}
		}
		else if(row==N/2+1)
		{
			for(int cst = 1;cst<=nst;cst++)
			{
				System.out.print("*");
			}
		}
		else
		{
			for(int cst2 = 1;cst2<=nst2;cst2++)
			{
				if(row==N)
				{
					System.out.print("*");
				}
				else
				{
					System.out.print(" ");
				}	
			}
			for(int cst1=1;cst1<=nst1;cst1++)
			{
				System.out.print("*");
			}
			for(int csp1 = 1;csp1<=nsp1;csp1++)
			{
				System.out.print(" ");
			}
			for(int cst1=1;cst1<=nst1;cst1++)
			{
				System.out.print("*");
			}
		}
			
		//preparation
		System.out.println();
		row = row + 1;
	}

}

}
not applicable for all test case, only applicable for N = 7 not for other conditions [N>=5 && N<=99]
pls rectify ASAP

@Naman_Gupta,
I have corrected your code. You don’t need 2 nst’s and also initial values seemed incorrect. https://ide.codingblocks.com/s/187091