Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

this is how the ouput look like Draw a 5 by 5 square: is it solid? (y/n) y Give

ID: 3628563 • Letter: T

Question

this is how the ouput look like

Draw a 5 by 5 square: is it solid? (y/n) y
Give me the character to draw the border: b
Give me the character to draw the inner solid portion: i
bbbbb
biiib
biiib
biiib
bbbbb
Try again? (y/n) y
Draw a 5 by 5 square: is it solid? (y/n) n
Give me the character to draw the border: e
eeeee
e e
e e
e e
eeeee
Try again? (y/n) n
See you later!
=====================================================================
and this is what i have and my problem is on the output, when the square is not solid
it's still asking to put character for the inner portion. how do you make it not show for the no solid part

#include <iostream>
using namespace std;

int main ( )

{
char answer, border, ans, inn ;
bool isSolid;

do
{
cout << "Is the sqaure solid???? ";
cin >> answer;

if (answer == 'y')
isSolid = true;

else
isSolid = false;
cout << "give me the character to draw ";
cin >> border ;
cout << "give me the character to fill in the inner portion ";
cin >> inn;

if ( isSolid == true )
{
cout << border << border << border << border << border << endl;
cout << border << inn << inn << inn << border << endl;
cout << border << inn << inn << inn << border << endl;
cout << border << inn << inn << inn << border << endl;
cout << border << border << border << border << border << endl;
}

else

{
cout << border << border << border << border << border << border << endl;
cout << border << " " << " " << " " << " " << border << endl;
cout << border << " " << " " << " " << " " << border << endl;
cout << border << " " << " " << " " << " " << border << endl;
cout << border << border << border << border << border << border << endl;
}




cout << "One more time? y/n? ";
cin >> ans;
}

while (ans == 'y');

cout << "Okay, bye then=) ";

cout <<"Press any key to exit... ";
char c;
cin >> c;




return 0;

}

Explanation / Answer

#include <iostream>
using namespace std;

int main ( )

{
char answer, border, ans, inn ;
bool isSolid;

do
{
cout << "Is the sqaure solid???? ";
cin >> answer;

if (answer == 'y')
isSolid = true;

else
isSolid = false;
cout << "give me the character to draw ";
cin >> border ;

if ( isSolid == true )
{

cout << "give me the character to fill in the inner portion ";
cin >> inn;

cout << border << border << border << border << border << endl;
cout << border << inn << inn << inn << border << endl;
cout << border << inn << inn << inn << border << endl;
cout << border << inn << inn << inn << border << endl;
cout << border << border << border << border << border << endl;
}

else

{
cout << border << border << border << border << border << border << endl;
cout << border << " " << " " << " " << " " << border << endl;
cout << border << " " << " " << " " << " " << border << endl;
cout << border << " " << " " << " " << " " << border << endl;
cout << border << border << border << border << border << border << endl;
}




cout << "One more time? y/n? ";
cin >> ans;
}

while (ans == 'y');

cout << "Okay, bye then=) ";

cout <<"Press any key to exit... ";
char c;
cin >> c;




return 0;

}