i am having problems with this assignment :
Write a program that prints an N by N box on the screen as follows:
Please enter a number between 2 and 10: 5
-----
| |
| |
| |
-----
Press any key to continue . . .
Note that there are 5 dashes (-) on the top and bottom row, and pipe characters (|)
for the sides in the middle rows. In the example there are 3 spaces between each
pipe character, making 5 characters across. So, this is a 5 by 5 box.
Check that the number is between 2 and 10; if out of bounds, display an error message
and END THE PROGRAM (do not keep asking for a valid number).
For example:
Please enter a number between 2 and 10: 11
That number is out of range.
Press any key to continue . . .
ANOTHER EXAMPLE:
Please enter a number between 2 and 10: 9
---------
| |
| |
| |
| |
| |
| |
| |
---------
Press any key to continue . . .
so far i have:
#include <iostream>
#include <string>
using namespace std;
int main()
{
int numExs, sum = 0;
cout << "Please enter a number between 2 and 10: " ;
cin >> numExs;
if ((numExs < 2) || (numExs > 10))
{
cout << "Entry is out of range";
}
else
{
for (int row = 1; row <= numExs; row++)
{
cout << "|" ;
for (int x = 1; x <= numExs; x++)
{
cout << "-" ;
}
cout << "|" << endl;
}
}
cout << endl;
}
can anyone help me out??
thanks.