///////
//
// Student: RussellLowke
//     T.F: Francis Crick
// Unit Two, Easy Supplementary - question 13 [worth 3pts],  7/1/2002
//
//  Write a program which will produce the outline of a 10x10 sqaure.
//  You may use any character for the border.
//  Modify the program to allow the user to select the size of the square.


#include <iostream>
#include <iomanip>

// constants
const char BORDER = '#';

// global vars
int squareSize = 10;


void topOrBottom()
{
    // print solid line of BORDER char
    for( int i = 0; i < squareSize; i++ ) {
        cout << BORDER;
    }
    cout << endl;
}


void printMiddle()
{
    // print left edge
    cout << BORDER;
    
    // print middle line
    for (int i = 1; i < squareSize-1; i++ ) {
        cout << ' ';
    }
    
    // print right edge
    cout << BORDER << endl;
}


void printSquare()
{
    // top of square
    topOrBottom();
    
    // middle of square
    for (int i = 0; i < squareSize-2; i++)
        printMiddle();
        
    // bottom of square
    topOrBottom();
}


void main()
{
    // get user input
    do {
       cout << "enter a square size (> 3)" << endl;
       cin >> squareSize;
       
       if (squareSize <= 3)
           cout << "ERROR: square size must be > 3" << endl;
           
    } while (squareSize <= 3);
    
    // print the square
    printSquare();
}