///////
//
// Student: RussellLowke
//     T.F: Francis Crick
// Unit Two, Hard Supplementary - question 24 [worth 5pts],  7/1/2002
//
//  Write a C++ program that reads a number - say n - from the
//  keyboard and types out a block letter H on the screen with
//  sides of size n


#include <iostream>
#include <iomanip>


// globals
int nBlock,       // n size
	x,            // counter for x loops
	y;            // counter for y loops
 

//
//  Ask user 'n' size
//
void getNSize()
{
	do {
		cout << "Enter n size: ";
		cin >> nBlock;
	 
		// check nBlock
		if (nBlock <= 0 || nBlock > 26)
			cout << "Number must > 0 and < 26 " << endl;
			
	} while (nBlock <= 0 || nBlock > 26);
}


//
// Draw the top or bottom part of the H
//
void drawTopOrBottom()
{
	for (y = 1; y <= nBlock; y++) {
	
		// start a new line
		cout << endl << "  ";
	  
		for (x = 1; x <= nBlock; x++) {
			cout << "*";
		}
	  
		for (x = 1; x <= nBlock; x++) {
			cout << " ";
		}
	  
		for (x = 1; x <= nBlock; x++) {
			cout << "*";
		}
	}
}


//
// Draw the middle part of the H
//
void drawMiddle()
{
   for (y = 1; y <= nBlock; y++) {
   
		// start a new line
		cout << endl << "  ";
	  
		for (x = 1; x <= nBlock*3; x++) {
			cout << "*";
		}
	}
}


//
// Display H
//
void drawIt()
{
	// draw top then middle then bottom
	drawTopOrBottom();   // draw top part
	drawMiddle();        // draw middle part
	drawTopOrBottom();   // draw bottom part
   
	// finish
	cout << endl << endl;
}


//
// main
//
void main()
{
	char tryAgain = 'Y';  // varible for "try again"
	
	// main loop
	do {
		getNSize();   // ask user n size
		drawIt();     // draw letter H
	   
		// Try again?
		cout << "Want to try again? (y/n) ";
		cin >> tryAgain;
	
	} while (tryAgain == 'Y' || tryAgain == 'y');
}