Question: (a) Design and implement a program that uses for loops to print the following rectangular pattern with a user specified width, height and wall thickness.
(a) Design and implement a program that uses for loops to print the following rectangular pattern with a user specified width, height and wall thickness. Check the values entered by the user and, (a) simply output an error message (& stop) if any of the values are invalid (i.e not positive), and (b) display the rectangle but print a warning message if it does not have a hole in the middle!
| th, height & thickness: 5 6 2 ***** ***** ** ** ** ** ***** ***** | Enter width, height & thickness: 10 10 3 ********** ********** ********** *** *** *** *** *** *** *** *** ********** ********** ********** |
| Enter width, height & thickness: 10 5 3 ********** ********** ********** ********** ********** Oops... no hole! Once this is working, modify your program so that, after outputting the pattern, it will ask the user if they wish to create another pattern and, if the user responds 'Y' or 'y', does so --any other response causing the program to print the message "goodbye" and stop. Hint: your program will always try to create at least one rectangular pattern. | Enter width, height & thickness: 15 6 0 Error: all values must be positive! |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
