Question: You will write a program that draws boxes using asterisk characters (*) based on user specified input. The program asks the user for two inputs:

You will write a program that draws boxes using asterisk characters (*) based on user specified input. The program asks the user for two inputs: 1. width (should be integer) 2. should the box be drawn as a solid or not (character that is either 'y' or 'n') The program first validates the input with the following rules: 1. The width should be at least 2 and at most 40. 2. The answer to the second input should be either 'y','Y','N' or 'n'. Effectively we are allowing user to answer the question in either upper or lower-case. If the validation fails, the program prints an error message and repeats the process of asking the question. In other words, the program actually doesn't terminate, but just re-displays the question and again goes through the validation checks. If the validation succeeds, a box is drawn, and then the program terminates. The box is drawn using the asterisk (*) symbol, and the input width determines the width of the box. Whether the user wanted a solid or hollow box determines what gets drawn in the center regions of the box. Here are some sample runs of this program. Run 1 ===== Enter Width: 10 Should the box be solid (y/n)? x Error: input not understood, please enter valid inputs... Enter Width: -10 Should the box be solid (y/n)? y Error: input not understood, please enter valid inputs... Enter Width: 2 Should the box be solid (y/n)? y Here is your box: ** ** Run 2 ===== Enter Width: 2 Should the box be solid (y/n)? n Here is your box: ** **

Run 3 ===== Enter Width: 5 Should the box be solid (y/n)? n Here is your box: ***** * * * * * * *****

When the width is 2, both solid and hollow boxes naturally look the same (since the border themselves take up an asterisk).

This program would greatly benefit from loops. need help on how to do that on C++

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!