Question

Need this in C++. ASCII Art. Computer graphics were really awful when Personal Computers first came...

Need this in C++. ASCII Art. Computer graphics were really awful when Personal Computers first came to market. In fact, many computers would show spreadsheets and even full video games using only ASCII characters (look up Nethack, Angband, or even Medievia). We’ll start the beginning of your ASCII Art career by drawing squares that are based on user input.   Write a function called drawBox that takes in number representing the width of the square. In main, ask the user for a number and then “draw” a box of that size by calling that function. There are several ways to code this, but you must have one function that you call from main. If you create additional functions that are called from that function, you’re that much more powerful! Hint #1: this is done by drawing individual characters. Hint 2: drawing the top and bottom lines are the same. How would you draw just the second line of Sample Run #3 below? Hint 3: a size of 1 is a special case…

Your task is to design (pseudocode) and implement (source code). For the source code, name your class “A5_1” and put it into a file called “A5_1” (either .java, .cs or .cpp)

Document your code and properly label the input prompt and the outputs as shown below.

Sample run 1:

Enter the size of the box: 1

*

Sample run 2:

Enter the size of the box: 2

* *

* *

Sample run 3:

Enter the size of the box: 5

* * * * *

*       *

*       *

*       *

* * * * *

Sample run 4:

Enter the size of the box: 10

* * * * * * * * * *

*                 *

*                 *

*                 *

*                 *

*                 *

*                 *

*                 *

*                 *

* * * * * * * * * *

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<iostream>
using namespace std;
void drawBox(int n){
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(i==0||i==n-1)
cout<<"* ";
else if(j==0 || j==n-1)
cout<<"* ";
else
cout<<" ";
}
cout<<"\n";
}
cout<<endl;
}
int main()
{
int n;
cout<<"Enter the size of the box: ";
cin>>n;
drawBox(n);

return 0;
}

/*

PSEUDOCODE

DECLARE SIZE

READ SIZE

LOOP I=0 TO SIZE

LOOP J=0 TO SIZE

IF I==0 OR I==SIZE-1

PRINT("* ")

ELSE IF J==0 PR J==SIZE-1

PRINT("* )

ELSE

PRINT(" ")

END LOOP

PRINT("\n")

END LOOP

*/


Note : Please comment below if you have concerns. I am here to help you

If you like my answer please rate and help me it is very Imp for me

Add a comment
Know the answer?
Add Answer to:
Need this in C++. ASCII Art. Computer graphics were really awful when Personal Computers first came...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT