import java.util.Scanner;

/**
*Prints a octogon based on users input
*@author [Student Name]
*version 1.0
*/

public class Program3
{
	public static void main(String [] args)
	{
	
		
		//creates and sets the boolean escapeClause to 'true'
		boolean escapeClause = true;
				

do
{
		Scanner input = new Scanner(System.in);
		System.out.println("Please enter an integer between 1- 12");
		String Pound = "#";
		String Space = " ";
		
		
		try
		{	
			//sets the variable 'value' to the passed integer
			int value = input.nextInt();
			
			//runs while loop if the integer entered is greater than 12 or less than 0
			while (value > 12 || value < 1)
			{
				System.out.println("The integer must be between 1 - 12. Please try again.");
				value = input.nextInt();		
			}
			 	
			int value2 = value * 3;
			int value3 = value;
			int value4 = value2 - 1;
			int value5 = value3 - value;
			int value6 = value5;
			int value7 = value4;
			int value8 = value;

				
		
		
		
			//runs the for loop for the top quadrant 
			for (int x = value; x > 0; x--)
			{
				//for loop prints the appropriate number of spaces
				for (int i = value3; i > 0; i--)
				{	
					System.out.print(Space);
				}
			
			
				//for loop prints the appropriate number of #'s
				for (int y = value8; y > 0; y--)
				{
					System.out.print(Pound);
				}
			
			
			value3 --;
			value8 +=2;
			System.out.println("");
		
			}
		
			//runs the for loop for the middle quadrant
			for (int x = value; x > 0; x --)
			{
				//for loop prints the appropriate number of #'s
				for(int i = value2; i > 0; i--) 
				{
					System.out.print(Pound);
				}
			
			System.out.println("");
			
			
			
			}
		

			//runs the for loop for the bottom quadrant
			for (int x = value; x > 0; x --)
			{
				//for loop prints the appropriate number of spaces
				for(int i = value3; i >= 0 ; i --)
				{
					System.out.print(Space);
				}
			
			
				//for loop prints the appropriate number of #'s
				for(int y = value8; y > 2; y --)
				{
					System.out.print(Pound);
				}
			
			value3++;
			value8 -=2;
			System.out.println("");
			
			
		
			}	
			
			//allow the loop to exit if an acceptable integer was entered
			if(value <= 12 && value > 0)
			{
				escapeClause = true;
			}
			
			//makes the loop run again if an unacceptable integer was entered
			else
			{
				escapeClause = false;
			}
			
		}
		
		
		
		
		//catch statement runs if anything other than an integer is entered 
		catch(java.util.InputMismatchException e)
		{
			System.out.println("This is not an integer.");
			
			//causes the loop to run again
			escapeClause = false;	

		
		}
	
}
		
		//while boolean escapeClause is false the loop will run again
		while (escapeClause == false);
	
	
	

	
	
	
	}

}
