{ This program asks the user for letters and the size to draw the letters, then prints the letters in block style down the page. } program blockLetters (input, output); const BLANK = ' '; var letterSize, i : integer; letter : char; { Draw a bar of the given height and width. } procedure DrawBar (height, width: integer); var i, j: integer; begin for i := 1 to height do begin for j := 1 to width do begin write ('*'); end; writeln; end; end; { Draw a "left+right" of the given height and width. The thickness of each portion is about 1/4 of the width. } procedure DrawLandR (height, width : integer); var i, j, thickness: integer; begin thickness := width div 4; for i := 1 to height do begin for j := 1 to thickness do begin write ('*'); end; for j := thickness + 1 to width - thickness do begin write (BLANK); end; for j := width - thickness + 1 to width do begin write ('*'); end; writeln; end; end; { Draw a left side of the given height. The thickness of the left side is about 1/4 of the width. } procedure DrawLeft (height, width: integer); var i, j, thickness: integer; begin thickness := width div 4; for i := 1 to height do begin for j := 1 to thickness do begin write('*'); end; writeln; end; end; { Draw a right side of the given height. The thickness of the right side is about 1/4 of the width. } procedure DrawRight (height, width : integer); var i, j, thickness: integer; begin thickness := width div 4; for i := 1 to height do begin for j := 1 to letterSize - thickness do begin write (BLANK); end; for j := letterSize - thickness + 1 to letterSize do begin write ('*'); end; writeln; end; end; { Draw a block P of the given size. The top bar should be roughly 1/4 of the P's height, and the middle bar should be at the top of the bottom half. } procedure DrawP (letterSize: integer); var topHalfHt, barHt, wallHt, legHt: integer; begin barHt := letterSize div 4; {each bar should be around 1/4 of the P} topHalfHt := letterSize div 2; wallHt := topHalfHt - barHt; {stuff that isn't bar is "walls" of the P} legHt := letterSize - topHalfHt - barHt; {height of the leg of the P} DrawBar (barHt, letterSize); DrawLandR (wallHt, letterSize); DrawBar (barHt, letterSize); DrawLeft (legHt, letterSize); end; { Draw a block A of the given size. The top bar should be roughly 1/4 of the A's height, and the middle bar should be at the top of the bottom half. } procedure DrawA (letterSize : integer); var topHalfHt, barHt, wallHt, legHt: integer; begin barHt := letterSize div 4; {each bar should be around 1/4 of the A} topHalfHt := letterSize div 2; wallHt := topHalfHt - barHt; {stuff that isn't bar is "walls" of the A} legHt := letterSize - topHalfHt - barHt; {height of the legs of the A} DrawBar (barHt, letterSize); DrawLandR (wallHt, letterSize); DrawBar (barHt, letterSize); DrawLandR (legHt, letterSize); end; { Draw a block S of the given size. The bars should be roughly 1/4 of the S's height, with the middle bar roughly at the middle (slightly above if necessary). } procedure DrawS (letterSize : integer); var barHt, firstWallHt, secondWallHt: integer; begin barHt := letterSize div 4; firstWallHt := (letterSize - 3 * barHt) div 2; {three bars and two walls in an S} secondWallHt := letterSize - firstWallHt - 3 * barHt; {want lower wall to be a bit taller} DrawBar (barHt, letterSize); DrawLeft (firstWallHt, letterSize); DrawBar (barHt, letterSize); DrawRight (secondWallHt, letterSize); DrawBar (barHt, letterSize); end; { Draw a block C of the given size. The top and bottom bars should be roughly 1/4 of the C's height. } procedure DrawC (letterSize: integer); var barHt, middleHt: integer; begin barHt := letterSize div 4; {each bar should be around 1/4 of the C} middleHt := letterSize - barHt - barHt; {height of the rest of the C} DrawBar (barHt, letterSize); DrawLeft (middleHt, letterSize); DrawBar (barHt, letterSize); end; { Draw a block L of the given size. The bottom bar should be roughly 1/4 of the L's height. } procedure DrawL (letterSize: integer); var barHt, legHt : integer; begin barHt := letterSize div 4; {the bar should be around 1/4 of the L} legHt := letterSize - barHt; {height of the rest of the L} DrawLeft (legHt, letterSize); DrawBar(barHt, letterSize); end; begin write ('Size of letter? '); readln (letterSize); write ('Please type six letters: '); for i := 1 to 6 do begin read(letter); case letter of 'P', 'p': DrawP(letterSize); 'A', 'a': DrawA(letterSize); 'S', 's': DrawS(letterSize); 'C', 'c': DrawC(letterSize); 'L', 'l': DrawL(letterSize); end; writeln; end; end.