--------------------------------------------------------------------------- The rest of the class will be related to problem solving and the Ghostbusters and Waggle dancing bees handouts from today's class. I will try to integrate that discussion of problem solving with hints and lessons and debriefing from the current programming assignment. --------------------------------------------------------------------------- If this is your first ever programming class and you need help and hints on the triangular losing last letters word problem or on the ********* ******* Panthers ***** Panther *** Panthe * problem Pant Pan Pa P check the class web page and/or come see me for help. This mornings class gave lots of hints on how to do the n * square (or narrow rectangle visually on your Form window). ******* <---- n * needed for the top side of the rectangle 1st row * * * * <---- What is an inner row? Describe it in English. Q1 * * * * <---- How many of these inner rows are needed? Q2 * * ******* <---- n * needed for the bottom border last row Q2 is "How many of these inner rows are needed?" The above example consists of 7 rows, and its clear there are 5 rows needed between the 1st row and the last row. When n = 10, there would be 8 rows after 1st row and before the last row. In general, there will be n - 2 rows! 1st row of n * n - 2 rows of left edge * followed by spaces <----- How many spaces? followed by right edge * last row of n * Q1 is "WHAT is an inner row?" Describe it. Understand it. An inner row is an * followed by spaces followed by an *. Type an *, press spacebar 5 times, type another *, press Enter I II III IV Left edge *, n - 2 spaces, right edge *, advance to next line I II III IV The idea of top-down development and stepwise refinement is part of VET SAT AUC (Very Effective Thinking So As To Avoid Unmastered Complexity) - - - - - - - - - From the top level, the problem is described as" WHAT Print the n * by n * box (rectangle) on the form HOW Do the 1st line of n * Step 1 These 3 steps, the HOW Do the n - 2 inner lines Step 2 are a refinement of the Do the last line of n * Step 3 one step, the WHAT of the entire program. Step 1.a Using a for loop, print the n * one at a time and Step 1.b then advance to a new line by using print without ; Step 2.a Print the 1st * (the left edge * for an inner row) Step 2.b Print the n - 2 spaces that are inside or between * Step 2.c Print the last or closing or right edge * Step 2.d Advance to the next line, this one is done Do you see the STEPWISE REFINEMENT and the TOP DOWN DEVELOPMENT illustrated above? Do you see any Visual Basic code or do you see an example of pseudocode and of heeding the programming proverb: "RESIST THE URGE TO CODE"? Looks like 2.a and 2.c and 2.d are detailed enough and simple and clear enough to translate into Visual Basic, or we could take 2.a and/or 2.b and do the: 2.a.i. Print n *, one at a time, I am thinking FOR loop 2.a.ii. Advance to the next line (Print without an ;) 2.b needs to be refined. 2.b.i. print the n - 2 spaces 2.b.ii. advance to the next line That should be enough hints for the print an n by n hollow rectangle using * as the border! :-) See page 81 of textbook and review the STRING functions such as LEFT and MID and RIGHT and LEN to solve the UNI UN I problem..... Remember that for loops can specify a different STEP size for the ***** *** * problem....... Step 10 For i = 20 to 100 Step 10 print i; Next i Step -2 For i = 21 to 1 Step -2 print i; Next i ----------------------------------------------------------------------------- Step 1: Do the 1st line of n * Step 1.a Using a for loop, print the n * one at a time. Step 1.b Advance to a new line by using print without ; Step 2: Do the n - 2 inner lines Step 2 restated: For each line of the n - 2 "inner lines" do following print (produce) one of the inner lines (not the top, not the bottom) of the rectangle Next line Step 3: Do the last line of n * ------------------------------------------------------------------------------- Step 2 restated again to show details of what happens in the loop body.... For each line of the n - 2 lines do 2.a Print the 1st * (the left edge * for an inner row) 2.b Print the n - 2 spaces that are inside or between * 2.c Print the last or closing or right edge * 2.d Advance to the next line Next line How do you do step 2.b above? How can you print n - 2 spaces? It is another loop, nested within the For each line loop. ------ Your program will provide the following capabilities: