/******************
* Steven Giovneco *
* 7/22/2003       *
* Loop Practice   *
* Print Diamond   *
******************/

import java.io.*;

class diamond
{
	public static void main(String args[]) throws IOException
	{
		//declare an input stream reader
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

		//print a prompt and get the character to show
		System.out.print("Enter a character to make a diamond of: ");	
		char c = in.readLine().charAt(0);

		//print a prompt and get the number the number of rows
		System.out.print("Please enter the number of rows as a positive odd integer: ");
		int rows;

		//read user input until it is a valid entry
		do
		{
			rows = Integer.parseInt(in.readLine());
			if (rows < 1) System.out.print("The rows must be positive.  Try again: ");
			else if(rows%2==0) System.out.print("The rows must be odd.  Try again: ");
		}
		while (rows < 1 || rows%2==0);

		//used to determind number of characters and spaces to print
		//first row always has rows/2 (note: integer division) spaces
		//followed by 1 output character
		int numChars=1, numSpaces=rows/2;

		//loop control variables
		int row,j;

		//loop once for every row
		for(row=1;row<=rows;row++)
		{
			//loop once for every space
			for(j=0;j<numSpaces;j++)
				System.out.print(" ");
			
			//loop once for every output character
			for(j=0;j<numChars;j++)
				System.out.print(c);
			
			System.out.println(); //move to a new line
			
			//if we are before the middle row...
			if (row <= rows/2)
			{	
				numChars += 2;
				numSpaces --;
			}
			else  //otherwise...
			{
				numChars -= 2;
				numSpaces++;
			}	 
		} 
	}
}
