import java.util.Scanner;

public class Exam_Test {
	public static void main(String args[]) {

		Scanner input =new Scanner(System.in);
		int number;
		System.out.println(" Enter a Number : ");
		number = input.nextInt();
		
		
	
		
		for (int i = 0; i <= number; i+=2) 
		{

			for (int j = number; j >= i; j--)

			{
				System.out.print(" ");
			
				if (j == i) 
				{
					for (int d = 0; d <= i; d++) 
					{
						System.out.print(" ");
						System.out.print("*");
					}
				}
			}
			
			
			System.out.println("");
		}
		
		
		if (number %2==0)
			
		{
		
	
		for (int i = number - 2 ; i >= 0; i-=2) 
		
		{
			

			for (int j = number; j >= i; j--)

			{
				System.out.print(" ");
			
				if (j == i) 
				{
					for (int d = 0; d <= i; d++) 
					{
						System.out.print(" ");
						System.out.print("*");
					}
				}
			}
			
			
			System.out.println("");
		}
		}
		else
			
		{
			{
				
				
				for (int i = number - 3 ; i >= 0; i-=2) 
				
				{
					

					for (int j = number; j >= i; j--)

					{
						System.out.print(" ");
					
						if (j == i) 
						{
							for (int d = 0; d <= i; d++) 
							{
								System.out.print(" ");
								System.out.print("*");
							}
						}
					}
					
					
					System.out.println("");
				}
				}
		}
	}

}

You need to ask a question if you expect to get any help. Tell us specifically where you are encountering problems. Also, please use code tags to make the code more readable.