i need help creating a rectangle where the user creates the border and fills in the empty space with any symbol they want.

it should look like this

#######
#@@@@#
#@@@@#
#@@@@#
#######

mine only looks like this

#
@@@@@
#
@@@@@
#
@@@@@

any help??? heres my code:

char b;// character used to draw border of rectangle
        char f;//character used to fill the rectangle
        cout << "What character would you like to use to draw the border of your rectangle?";
        cin >> b;
        cout << "What character would you like to use to fill the rectangle?";
        cin >> f;
        for (int i = 0; i < rectangleLength; i++)
        {
            cout << b;
            cout <<"\n";

            for (int j = 0; j < rectangleWidth; j++)
            {
                cout << f;
            }
            cout << "\n";

There are two types of lines in your rectangle. The top and bottom line both look alike and all the lines in between have the same appearance. The top and bottom all use the same symbol. The interior lines all have the first and last char the same as the top and bottom line but the interior char are different.

Start out by writing a program that can write a line of the x number of the same char where x is input by user.

Then add code to write a line x char long but both the first and last char are different than all the interior char.

Then use that knowledge to write the real program.

First create a function that makes a rectangle like so :

#######
#     #
#     #
#     #
#######

After you get that , then its a simple change.

USE THE CODE TAGS TO POST YOUR CODE
--------------------------------------------------------------------------------------

We have two lines in the rectangle, as Lerner said, the top and the bottom lines...
So your code should look like this:
1. Draw the top line of the rectangle.
2. Use a loop to draw the other lines simply by printing one character of the borders and then the characters filling the rectange, then the character of the right side of the border.
3. When you reach the bottom Draw it with the border characters.

Try it and if you faced problems, post them and we'll be glad to help....

Wallah

for( int i = 0; i < Stat.x; i++ )
		cout << a;
	cout << endl;

	for( int i = 0; i < Stat.y - 2; i++ )
	{
		cout << a;
		for( int k = 0; k < Stat.x - 2; k++ )
			cout << b;
		cout << a << endl;
	}
	for( int i = 0; i < Stat.x; i++ )
		cout << a;

A nice shell

commented: Any of those folks could have done that too +0
commented: Let the OP get a turn? -1

thanks i figured it out

thank u bro i cant believe i didnt see that! thanks

thanks

np, but I recommend the edit button to your posts o:

now for some reason the program wont work correctly...previously it had worked and created a rectangle and allowed the user to fill in the middle and now it only displays the first line of the rectangle

for (int i = 0; i < rectangleLength; i++)
		{
			for (int j = 0; j < rectangleWidth; j++)
			{				
				if ( i == 0  || i == rectangleLength - 1)
				{
					cout << b;

				}else if ( j == 0  || j == rectangleWidth - 1)
				{
					cout << b;
				}
				else 
				{
					cout << f;
				}
			}
			cout << "\n";
		}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.