#include void printChar (int n, char ch); void hollowBox (int height, int width, char ch); void hollowBoxAt (int height, int width, char ch, int margin); void printStairCase (int treadHeight, int treadDepth, int steps, char ch); void StairCaseDesigner (void); void WaitForAnyKeyToContinue (void); #define MAXLINELENGTH 78 #define MAXHEIGHT 21 /* Start by writing the function void printChar (int n, char ch); which displays the character ch n times across the screen, with no preceding, following, or intervening other characters. Hint: you can adapt such a function from examples in the lecture slides. If n > MAXLINELENGTH, print an error message and no other output. */ /* Write the function void hollowBox (int height, int width, char ch); which displays (starting at the first at the current cursor position) a box shape, hollow on the inside, with the character ch along the outside edges, of the given height and width. For example, hollowBox (3, 5, *); would print ***** * * ***** If height > MAXHEIGHT or width > MAXLINELENTH, there should be an error message but no other output. You must use printChar in your solution. Or -- you could implement hollowBoxAt (see just below) first, and then implement hollowBox as a one-line call to hollowBoxAt! */ /*Write the function void hollowBoxAt (int height, int width, char ch, int margin); which works just like hollowBox, except the box is indented from the left by a margin of blanks. For example hollowBox (3, 5, *, 8); would print ***** * * ***** You should print an error message if any line would go off the screen i.e., belonger than MAXLINELENGTH. Your solution should use printChar for the entire box (except for the newlines separating the lines of the box). [You might at first be tempted to try to call HollowBox from inside HollowBoxAt. Actually, the reverse tactic will work better: implement HollowBox to call HollowBoxAt. If you don't see how to do this at first, implemement the two functions separately, get each working, and then go back and reimplement HollowBox.] */ /* Write the function void printStairCase (int treadHeight, int treadDepth, int steps, char ch); whiich should print a staircase pattern, where each tread is of the given treadHeight, and there are steps stairs, outlined with character ch. For example, here is a staircase with tread height of 3, tread depth of 4, and 3 steps, using the character ch: **** * * **** ******** * * ******** ************ * * ************ Print an error message if the total staircase would be greater than MAXHEIGHT. Use HollowBoxAt in your implementation. */ /*Write the function StairCaseDesigner which asks the user for the tread height, and then displays a staircase that almost fills the screen (it should not scroll off, or overflow the lines, but should use as many lines as are possible and still have complete steps. Any (printable) character can be passed as a parameter to be used in printing the staircase. Once StairCaseDesigner has figured out what the tread depth and number of steps is, it should print those values, and then make ONE call to printStairCase. No calls to printChar or hollowBox or hollowBoxAt should be needed. */ /*Finally, modify main to create an infinite loop for calling StairCaseDesigner (see comments in main). */ void printChar (int n, char ch) { } /*end printChar*/ void hollowBox (int height, int width, char ch) { } /*end hollowBox*/ void hollowBoxAt (int height, int width, char ch, int margin) { } /* end hollowBoxAt*/ void printStairCase (int treadHeight, int treadDepth, int steps, char ch) { } /*end printStairCase*/ void StairCaseDesigner (void) { } /*end StairCaseDesigner */ /* * WaitForWaitForAnyKeyToContinue * ----------------------- * Input: n/a * Output: n/a * Prompt the user and wait until he/she presses a non-white-space key. */ #define WAIT_MESSAGE "\nHit any character, then enter to continue\n" void WaitForAnyKeyToContinue(void) { char c1; printf(WAIT_MESSAGE); scanf(" %c", &c1); /* " %c" is needed to consume leading white-space */ } /*Following are some test cases. This function can be called from main, and modified to comment out or add new cases as needed. */ /*PLEASE DO NOT MODIFY THIS FUNCTION! IT WILL BE USED TO HELP GRADE YOUR PROGRAM */ void testcases () { printf ("\nTestcases for printChar\n"); printChar (1, '1'); printChar (3, '3'); printChar (15, '*'); printChar (6, ' '); printChar (2, '^'); printChar (300, 'e'); /*should give an error */ WaitForAnyKeyToContinue(); printf ("\nTestcases for hollowBox\n"); hollowBox (1,1, '*'); hollowBox (3,4, '@'); hollowBox (5,20, '#'); WaitForAnyKeyToContinue(); printf ("\nTestcases for hollowBoxAt\n"); hollowBoxAt (1,1, '*', 10); hollowBoxAt (3,4, '@', 2); hollowBoxAt (5,20, '#', 5); WaitForAnyKeyToContinue (); printf ("\nTestcases for printStairCase\n"); printStairCase (3, 5, 1, '*'); WaitForAnyKeyToContinue(); printStairCase (6, 8, 3, '0'); WaitForAnyKeyToContinue(); printStairCase (2, 7, 5, '-'); WaitForAnyKeyToContinue (); printStairCase (1, 4, 15, '|'); } /*end testcases*/ /*PLEASE DO NOT MODIFY MAIN, except as noted in the comment below. IT WILL BE USED TO HELP GRADE YOUR PROGRAM. */ int main (void) { testcases (); /*test functions, except for stair case designer*/ /* Modify the code to put the following three statements inside an infinite loop. */ StairCaseDesigner(); printf ("\nPress CNTRL-C to end program. "); WaitForAnyKeyToContinue(); return 0; } /*end main*/